...
int a[n+1];
int maxx = -1;
cin >> a[0] >> a[1];
for (int i = 2; i < n; i++)
{
cin >> a[i];
int d;
d = a[i-2] + a[i - 1] + a[i];
if (d > maxx)
maxx = d;
}
cout << maxx;
return 0;
...
int a[n+1];
int maxx = -1;
cin >> a[0] >> a[1];
for (int i = 2; i < n; i++)
{
cin >> a[i];
int d;
d = a[i-2] + a[i - 1] + a[i];
if (d > maxx)
maxx = d;
}
cout << maxx;
return 0;