What's the problem in this code?


#1

#include
#include
using namespace std;
int z;
int max(int q,int r)
{
if(q>r)
z=q;
else
z=r;
return z;
}
int main()
{
int i,z=-100,j,result=0,n,a[n];
1<=i,j<=n;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
for(j=1;j<n;j++)
{
if(i+j>n)
break;
result=abs(a[i]-a[i+j-1])+abs(1-j);
z=max(z,result);
}
}

cout<<z;

}