22 lines
348 B
C++
22 lines
348 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
ios_base::sync_with_stdio(false);
|
|
cin.tie(NULL);
|
|
freopen("max3.inp", "r", stdin);
|
|
|
|
int n;
|
|
cin >> n;
|
|
vector<int> a(n);
|
|
for (int &i : a)
|
|
cin >> i;
|
|
|
|
int res = 0;
|
|
for (int i = 0; i < n - 2; i++)
|
|
res = max(res, a[i] + a[i + 1] + a[i + 2]);
|
|
|
|
cout << res << '\n';
|
|
}
|