#include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} int N; vector a, sum; bool check(int m, int x){ int y = x / 2; // if(m == 0) return true; if(x%2) { if(m > min(y, N - y)) { return false; } else { int a = sum[y] - sum[y - m]; int b = sum[N] - sum[N - m]; if(a <= b) return true; else return false; } } else { if(m > min(y, N - y)) { return false; } else { int a = sum[y] - sum[y - m]; int b = sum[N] - sum[N - m]; if(a <= b) return true; else return false; } } } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout<>N; a.resize(N); sum.resize(N+1); for(int i = 0; i < N; i++){ cin>>a[i]; a[i] <<= 1; // cout<<"i = "<> 1; if(check(m, i)){ l = m; } else { h = m; } } // cout<<"i = "<