rendered paste body#include<iostream>
using namespace std;
int main()
{
long int i,j,tm,n,tot=0,tots=0,req=0,reqs=0,cnt=0;
long int *a;
long int max = 0;
cin>>n;
a = (long int *)malloc(sizeof(long int) * n);
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
tm = a[i];
cnt = 0;
tot = 0;
tots = 0;
for(j=i;j<n;j++)
{
if(a[j] > tm)
tm = a[j];
req = tm *(tm + 1) /2;
reqs = tm *(tm + 1)*((2* tm) + 1) /6;
cout<<" --------------------- REQ 1s :"<< req << " 2s :"<< reqs <<endl;
cnt++;
tot+= a[j];
tots += (a[j] * a[j]);
cout<<" --------------------- TOT 1s : "<< tot << " 2s : "<< tots <<endl;
if(cnt == tm)
{
if(tot == req && tots == reqs)
{
cout<<":::: Equal.. "<<endl;
if(cnt > max)
max = cnt;
}
else
break;
}
}
}
cout<<"MAX :: "<<max<<endl;
getchar();
getchar();
return 0;
}