# Problem Link

Loop Through**Author:**pskalbhav1

# Difficulty

EASY# Prerequisites

Math, Implementation# Problem Statement

Andy wants to watch the film, ‘Back to The Future’, a film from the 80s. To watch this movie, he needs to use a VHS player. The VHS player, upon turning on, presents a password prompt to Andy: he is given a random sequence of numbers N, and he is only meant to pick out the largest subset of consecutive numbers. Only if Andy picks the correct subset of numbers, finds its length and enters the length as the password, can he load into the VHS menu. Can you help Andy get into the VHS menu?# Solution

```
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back;
int main()
{
ll n,a[10000],i;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
ll c=0,ans=0;
sort(a,a+n);
for(i=0;i<n-1;i++)
{
if(a[i]+1==a[i+1])
{
c++;
}
else
{
ans=max(ans,c);
c=0;
}
}
cout<<ans+1<<endl;
return 0;
}
```