#include using namespace std; int main() { int n; int a[200000+1]; int i; cin >> n; for (i=0; i> a[i]; int min = 300000000+1; int x; for (i=0; i a[i+2])) || ((a[i] > a[i+1]) && (a[i+1] < a[i+2]))) { x = a[i]+a[i+1]+a[i+2]; if (x < min) min = x; } } if (min == 300000000+1) min = -1; cout << min; return 0; }