#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n;
cin >> n;
int couti = 0;
int maxn = 0;
int a[1000] = { 0 };
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
for (int i = 1; i < n; i++)
{
if (a[i] - a[i - 1] == 1)
{
couti++;
}
else
couti = 0;
maxn = max(couti, maxn);
}
cout << maxn+1;
}
转自MicDZ先生的做法