#include <bits/stdc++.h>   using namespace std;   template <typename T>   using minpq = priority_queue<T, vector<T>, greater<T>>;   const int N = 5e5 + 5;   int n;   long long a[N], x;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = (0); i < ((n + 1) / 2); i++) cin >> a[i];     cin >> x;     long long sum = 0, mn = n / 2 + 1, mx = n;     vector<pair<long long, long long>> ve;     for (int i = (n + 1) / 2 - 1; i >= 0; i--) {       sum += a[i];       if (x > 0) {         if (sum <= 0) {           mn = max(mn,                    min((long long)n - i + 1, (-sum + x) / x + (n + 1) / 2 - i));         }       } else if (x < 0) {         if (sum > 0) {           long long val = (sum - x - 1) / -x - 1 + (n + 1) / 2 - i;           if (n - i + 1 > val) {             ve.emplace_back(val + 1, n - i);           }         } else {           mn = max(mn, (long long)n - i + 1);         }       } else if (sum <= 0) {         mn = max(mn, (long long)n - i + 1);       }     }     reverse((ve).begin(), (ve).end());     for (auto &p : ve) {       if (p.first <= mx && mx <= p.second) {         mx = p.first - 1;       }     }     if (mn <= mx) {       cout << mx <<   n ;     } else {       cout <<  -1 n ;     }   }   