#include<bits/stdc++.h>
using namespace std;

const long long maxn = 5e5 + 10;
const long long inf = 1e18;

long long n;
long long K;
long long ans;
long long sum;
long long a[maxn];
long long seg[4 * maxn];
long long lazy[4 * maxn];

void in();
void solve();
void out();
void upd(long long, long long, long long, long long ,long long, long long);
long long get(long long, long long ,long long ,long long ,long long);
void push(long long);

int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    in();
    solve();
    out();
}

void in(){
    cin >> n;
    for(long long i = 0; i < (n + 1) / 2; i++)
        cin >> a[i];
    cin >> K;
}

void solve(){
    for(long long i = 0; i < n; i++){
        sum += a[i];
        upd(1, 0, n, i, i + 1, a[i]);
    }
    if(K * (n / 2) + sum > 0){
        ans = n;
        return;
    }
    ans = -1;
    sum += K * (n / 2);
    for(long long i = 0; i < n; i++){
        long long MX = K * (i + 1);
        MX = max(MX, get(1, 0, n, 0, i + 1));
        if(sum - MX > 0){
            ans = n - i - 1;
            return;
        }
        upd(1, 0, n, 0, i + 1, K);
    }
}

void upd(long long id, long long l, long long r, long long L, long long R, long long x){
    if(r <= L || R <= l)
        return;
    if(L <= l && r <= R){
        seg[id] += x;
        lazy[id] += x;
        return;
    }
    push(id);
    long long mid = (l + r) >> 1;
    upd(id << 1, l, mid, L, R, x);
    upd(id << 1 | 1, mid, r, L, R, x);
    seg[id] = max(seg[id << 1], seg[id << 1 | 1]);
}

long long get(long long id, long long l, long long r, long long L, long long R){
    if(r <= L || R <= l)
        return -inf;
    if(L <= l && r <= R)
        return seg[id];
    push(id);
    long long mid = (l + r) >> 1;
    return max(get(id << 1, l, mid, L, R), get(id << 1 | 1, mid, r, L, R));
}

void push(long long id){
    seg[id << 1] += lazy[id];
    seg[id << 1 | 1] += lazy[id];
    lazy[id << 1] += lazy[id];
    lazy[id << 1 | 1] += lazy[id];
    lazy[id] = 0;
}

void out(){
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;

const long long maxn = 5e5 + 10;
const long long inf = 1e18;

long long n;
long long K;
long long ans;
long long sum;
long long a[maxn];
long long seg[4 * maxn];
long long lazy[4 * maxn];

void in();
void solve();
void out();
void upd(long long, long long, long long, long long ,long long, long long);
long long get(long long, long long ,long long ,long long ,long long);
void push(long long);

int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    in();
    solve();
    out();
}

void in(){
    cin >> n;
    for(long long i = 0; i < (n + 1) / 2; i++)
        cin >> a[i];
    cin >> K;
}

void solve(){
    for(long long i = 0; i < n; i++){
        sum += a[i];
        upd(1, 0, n, i, i + 1, a[i]);
    }
    if(K * (n / 2) + sum > 0){
        ans = n;
        return;
    }
    if(K > 0){
        ans = -1;
        return;
    }
    ans = -1;
    sum += K * (n / 2);
    for(long long i = 0; i < n; i++){
        long long MX = K * (i + 1);
        MX = max(MX, get(1, 0, n, 0, i + 1));
        if(sum - MX > 0){
            ans = n - i - 1;
            return;
        }
        upd(1, 0, n, 0, i + 1, K);
    }
}

void upd(long long id, long long l, long long r, long long L, long long R, long long x){
    if(r <= L || R <= l)
        return;
    if(L <= l && r <= R){
        seg[id] += x;
        lazy[id] += x;
        return;
    }
    push(id);
    long long mid = (l + r) >> 1;
    upd(id << 1, l, mid, L, R, x);
    upd(id << 1 | 1, mid, r, L, R, x);
    seg[id] = max(seg[id << 1], seg[id << 1 | 1]);
}

long long get(long long id, long long l, long long r, long long L, long long R){
    if(r <= L || R <= l)
        return -inf;
    if(L <= l && r <= R)
        return seg[id];
    push(id);
    long long mid = (l + r) >> 1;
    return max(get(id << 1, l, mid, L, R), get(id << 1 | 1, mid, r, L, R));
}

void push(long long id){
    seg[id << 1] += lazy[id];
    seg[id << 1 | 1] += lazy[id];
    lazy[id << 1] += lazy[id];
    lazy[id << 1 | 1] += lazy[id];
    lazy[id] = 0;
}

void out(){
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll a[500005];
ll suff[500005];

int main() {
	ll n;
	scanf("%I64d", &n);
	ll sum = 0;
	for (int i=0 ; i<(n+1)/2 ; i++) {
		scanf("%I64d", a+i);
		sum += a[i];
	}
	ll x;
	scanf("%I64d", &x);
	sum += n/2*x;
	if (x>=0) {
		if (sum > 0) printf("%I64d\n", n);
		else printf("-1\n");
	} else {
		for (int i=(n+1)/2-1 ; i>=0 ; i--) {
			suff[i] = suff[i+1]+a[i];
		}
		ll p = 0;
		ll ost = n/2*x;
		for (ll k=n ; k>n/2 ; k--) {
			ll np = n-k;
			if (suff[p]+p*x>suff[np]+np*x) p = np;
			if (suff[p]+(k-((n+1)/2)-p)*x>0) {
				printf("%I64d\n", k);
				return 0;
			}
		}
		printf("-1\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll a[500005];
ll suff[500005];

int main() {
	ll n;
	scanf("%I64d", &n);
	ll sum = 0;
	for (int i=0 ; i<(n+1)/2 ; i++) {
		scanf("%I64d", a+i);
		sum += a[i];
	}
	ll x;
	scanf("%I64d", &x);
	sum += n/2*x;
	if (x>=0) {
		if (sum > 0) printf("%I64d\n", n);
		else printf("-1\n");
	} else {
		for (int i=(n+1)/2-1 ; i>=0 ; i--) {
			suff[i] = suff[i+1]+a[i];
		}
		ll p = 0;
		for (ll k=n ; k>n/2 ; k--) {
			ll np = n-k;
			if (suff[p]+p*x>suff[np]+np*x) p = np;
			/*cout <<"!!!"<<k-((n+1)/2)+p<<endl;
			cout <<"k = "<<k<<"  minimal = "<<suff[p]<<"+"<<(k-((n+1)/2)+p)*x<<endl;
			cout <<"p = "<<p<<endl;*/
			if (suff[p]+(k-((n+1)/2)+p)*x>0) {
				printf("%I64d\n", k);
				return 0;
			}
		}
		printf("-1\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll a[500005];

int main() {
	ll n;
	scanf("%I64d", &n);
	ll sum = 0;
	for (int i=0 ; i<(n+1)/2 ; i++) {
		scanf("%I64d", a+i);
		sum += a[i];
	}
	ll x;
	scanf("%I64d", &x);
	sum += n/2*x;
	if (x>=0) {
		if (sum > 0) printf("%I64d\n", n);
		else printf("-1\n");
	} else {
		ll maxx = a[(n+1)/2-1];
		ll curr = a[(n+1)/2-1];
		int ind = (n+1)/2-1;
		for (int i=(n+1)/2-2 ; i>=0 ; i--) {
			curr += a[i];
			if (curr > maxx) {
				maxx = curr;
				ind = i;
			}
		}
		ll ost = n/2*x;
		if (ost+maxx<=0) {
			printf("-1\n");
			return 0;
		}
		int m = n-ind;
		sum -= n/2*x;
		sum += (m-(n+1)/2)*x;
		if (sum<=0) printf("-1\n");
		else printf("%d\n", m);
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll a[500005];
ll suff[500005];

int main() {
	ll n;
	scanf("%I64d", &n);
	ll sum = 0;
	for (int i=0 ; i<(n+1)/2 ; i++) {
		scanf("%I64d", a+i);
		sum += a[i];
	}
	ll x;
	scanf("%I64d", &x);
	sum += n/2*x;
	if (x>=0) {
		if (sum > 0) printf("%I64d\n", n);
		else printf("-1\n");
	} else {
		for (int i=(n+1)/2-1 ; i>=0 ; i--) {
			suff[i] = suff[i+1]+a[i];
		}
		ll p = 0;
		ll ost = n/2*x;
		ll off = 0;
		for (ll k=n ; k>n/2 ; k--) {
			if (ost+suff[n-k]>0 and suff[p]+(k-((n+1)/2)-p)*x>0) {
				printf("%I64d\n", k);
				return 0;
			}
			ll np = n-k;
			if (suff[p]-p*x>suff[np]-np*x) p = np;
		}
		printf("-1\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll a[500005];
ll suff[500005];

int main() {
	ll n;
	scanf("%I64d", &n);
	ll sum = 0;
	for (int i=0 ; i<(n+1)/2 ; i++) {
		scanf("%I64d", a+i);
		sum += a[i];
	}
	ll x;
	scanf("%I64d", &x);
	sum += n/2*x;
	if (x>=0) {
		if (sum > 0) printf("%I64d\n", n);
		else printf("-1\n");
	} else {
		for (int i=(n+1)/2-1 ; i>=0 ; i--) {
			suff[i] = suff[i+1]+a[i];
		}
		ll p = 0;
		ll ost = n/2*x;
		ll off = 0;
		for (int k=n ; k>n/2 ; k--) {
			if (ost+suff[n-k]>0 and suff[p]+(k-((n+1)/2)-p)*x>0) {
				printf("%d\n", k);
				return 0;
			}
			int np = n-k;
			if (suff[p]+(k-((n+1)/2)-p)*x>suff[np]+(k-((n+1)/2)-np)*x) p = np;
		}
		printf("-1\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll a[500005];
ll suff[500005];

int main() {
	ll n;
	scanf("%I64d", &n);
	ll sum = 0;
	for (int i=0 ; i<(n+1)/2 ; i++) {
		scanf("%I64d", a+i);
		sum += a[i];
	}
	ll x;
	scanf("%I64d", &x);
	sum += n/2*x;
	if (x>=0) {
		if (sum > 0) printf("%I64d\n", n);
		else printf("-1\n");
	} else {
		for (int i=(n+1)/2-1 ; i>=0 ; i--) {
			suff[i] = suff[i+1]+a[i];
		}
		ll p = 0;
		ll ost = n/2*x;
		for (ll k=n ; k>n/2 ; k--) {
			if (ost+suff[n-k]>0 and suff[p]+(k-((n+1)/2)-p)*x>0) {
				printf("%I64d\n", k);
				return 0;
			}
			ll np = n-k;
			if (suff[p]+p*x>suff[np]+np*x) p = np;
		}
		printf("-1\n");
	}
	return 0;
}


#define ICC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI acos(-1)
#include<time.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<iostream>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
clock_t start,finish;
const ll MOD=(1?100000000000000007:233333333333333333);
const int mod=(1?1000000007:998244353);
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
   if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int st[4][2]={1,0,0,1,-1,0,0,-1};

/*线性素数
int p[N],vis[N];
int getpre(){
    memset(vis,1,sizeof(vis));vis[0]=vis[1]=0;
    int sum=0;
    for(int i=2;i<=1e5;i++){
        if(vis[i])p[sum++]=i;
        for(int j=0;j<sum&&i*p[j]<=1e5;j++){
            vis[i*p[j]]=0;
            if(i%p[j]==0)break;
        }
    }
    return sum;
}
*/

/*前向星
int head[N],tot;
void init(int n){tot=1;for(int i=0;i<=n;i++)head[i]=0;}
struct edge{int to,next,w;}e[N<<1];
void add(int u,int v,int w){e[tot].to=v,e[tot].w=w,e[tot].next=head[u],head[u]=tot++;}
*/

/*优先队列优先级
struct node{
    int x,y;
    bool operator < (const node & a) const{
        return x<a.x;  //大的优先级高
    }
};
*/

/*树状数组
int tree[N];
void add(int i){for(;i<=n;i+=i&-i)tree[i]++;}
int getsum(int i){int s=0;for(;i>0;i-=i&-i)s+=tree[i];return s;}
*/

/*线性递推组合数板子
struct CC
{
    static const int M=200010;
    ll fac[M],inv[M]; //fac[i]等于i!，inv[i]等于1/i!
    CC(){
        fac[0]=1;
        for(int i=1;i<M;i++)fac[i]=fac[i-1]*i%mod;
        inv[M-1]=poww(fac[M-1],mod-2);
        for(int i=M-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
    ll operator()(ll a,ll b){ //a>=b
        if(a<b||a<0)return 0;
        return fac[a]*inv[a-b]%mod*inv[b]%mod;
    }
}C;   //int c=C(a,b);
*/

/*点P0到线P1,P2的距离
double dist(double x1,double y1,double x2,double y2,double x0,double y0){
    return fabs((y2-y1)*x0+(x1-x2)*y0+(x2*y1)-(x1*y2))/hypot(y2-y1,x1-x2);
}
*/

//freopen("a.in","r",stdin);freopen("a.out","w",stdout);
//priority_queue<ll,vector<ll>,greater<ll> >q;  //(greater) | (less)
//unordered_map<int,int>q;
//map<int,int>::iterator it;
//getline(cin,s);
//reverse(s.begin(),s.end());   //翻转字符串
//floor(); 向下取整 // ceil(); 向上取整
//cnt=__builtin_popcount(x); 计算x的二进制中1的个数
//fflush(stdout); 清空输出缓存区
//s.insert(x); s.erase(it);  //set的插入删除
//lower_bound(begin,end,num); 第一个大于或等于num的数字
//upper_bound(begin,end,num); 第一个大于num的数字,返回地址
//fflush(stdout);能强制把缓存内容输出(加在交互题输出后)
//log(10);        以e为底的对数函数
//log10(100);     以10为底的对数函数
//log(8)/log(2);  计算log2^8,运用换底公式
//exp(1);         计算自然常数e
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
//hypot(double, double); 该函数返回两个参数的平方总和的平方根

//-----------------------------------------------------------------------------------------------------------------------------//

const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-9;
const int N=5e5+5;

int T,cas;
int n,m;
ll a[N];
int main()
{
    //scanf("%d",&T);
    while(~scanf("%d",&n))
    {
        vector<int>q;
        m=(n+1)/2;
        a[0]=0;
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        ll x;
        scanf("%lld",&x);
        for(int i=m+1;i<=n;i++)
        {
            a[i]=x;
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        if(q.size()==0)
        {
            printf("-1\n");
            continue;
        }
        int v=-1;
        for(int j=q.size()-1;j>=0;j--)
        {
            int d=q[j];
            int vis=1;
            for(int l=d+1,r=n;l<=r;l++,r--)
            {
                //printf("%lld \n",a[i]-a[i-v]);
                if(a[l]-a[l-d]<=0||a[r]-a[r-d]<=0)
                {
                    vis=0;
                    break;
                }
            }
            if(vis)
            {
                v=d;
                break;
            }
        }
        printf("%d\n",v);
    }
}


#define ICC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI acos(-1)
#include<time.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<iostream>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
clock_t start,finish;
const ll MOD=(1?100000000000000007:233333333333333333);
const int mod=(1?1000000007:998244353);
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
   if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int st[4][2]={1,0,0,1,-1,0,0,-1};

/*线性素数
int p[N],vis[N];
int getpre(){
    memset(vis,1,sizeof(vis));vis[0]=vis[1]=0;
    int sum=0;
    for(int i=2;i<=1e5;i++){
        if(vis[i])p[sum++]=i;
        for(int j=0;j<sum&&i*p[j]<=1e5;j++){
            vis[i*p[j]]=0;
            if(i%p[j]==0)break;
        }
    }
    return sum;
}
*/

/*前向星
int head[N],tot;
void init(int n){tot=1;for(int i=0;i<=n;i++)head[i]=0;}
struct edge{int to,next,w;}e[N<<1];
void add(int u,int v,int w){e[tot].to=v,e[tot].w=w,e[tot].next=head[u],head[u]=tot++;}
*/

/*优先队列优先级
struct node{
    int x,y;
    bool operator < (const node & a) const{
        return x<a.x;  //大的优先级高
    }
};
*/

/*树状数组
int tree[N];
void add(int i){for(;i<=n;i+=i&-i)tree[i]++;}
int getsum(int i){int s=0;for(;i>0;i-=i&-i)s+=tree[i];return s;}
*/

/*线性递推组合数板子
struct CC
{
    static const int M=200010;
    ll fac[M],inv[M]; //fac[i]等于i!，inv[i]等于1/i!
    CC(){
        fac[0]=1;
        for(int i=1;i<M;i++)fac[i]=fac[i-1]*i%mod;
        inv[M-1]=poww(fac[M-1],mod-2);
        for(int i=M-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
    ll operator()(ll a,ll b){ //a>=b
        if(a<b||a<0)return 0;
        return fac[a]*inv[a-b]%mod*inv[b]%mod;
    }
}C;   //int c=C(a,b);
*/

/*点P0到线P1,P2的距离
double dist(double x1,double y1,double x2,double y2,double x0,double y0){
    return fabs((y2-y1)*x0+(x1-x2)*y0+(x2*y1)-(x1*y2))/hypot(y2-y1,x1-x2);
}
*/

//freopen("a.in","r",stdin);freopen("a.out","w",stdout);
//priority_queue<ll,vector<ll>,greater<ll> >q;  //(greater) | (less)
//unordered_map<int,int>q;
//map<int,int>::iterator it;
//getline(cin,s);
//reverse(s.begin(),s.end());   //翻转字符串
//floor(); 向下取整 // ceil(); 向上取整
//cnt=__builtin_popcount(x); 计算x的二进制中1的个数
//fflush(stdout); 清空输出缓存区
//s.insert(x); s.erase(it);  //set的插入删除
//lower_bound(begin,end,num); 第一个大于或等于num的数字
//upper_bound(begin,end,num); 第一个大于num的数字,返回地址
//fflush(stdout);能强制把缓存内容输出(加在交互题输出后)
//log(10);        以e为底的对数函数
//log10(100);     以10为底的对数函数
//log(8)/log(2);  计算log2^8,运用换底公式
//exp(1);         计算自然常数e
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
//hypot(double, double); 该函数返回两个参数的平方总和的平方根

//-----------------------------------------------------------------------------------------------------------------------------//

const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-9;
const int N=5e5+5;

int T,cas;
int n,m;
ll a[N];
int main()
{
    //scanf("%d",&T);
    while(~scanf("%d",&n))
    {
        vector<int>q;
        m=(n+1)/2;
        a[0]=0;
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        ll x;
        scanf("%lld",&x);
        for(int i=m+1;i<=n;i++)
        {
            a[i]=x;
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        if(q.size()==0)
        {
            printf("-1\n");
            continue;
        }
        int v=-1;
        int cnt=0;
        for(int j=q.size()-1;j>=0;j--)
        {
            cnt++;
            int d=q[j];
            int vis=1;
            for(int l=d+1,r=n;l<=r;l++,r--)
            {
                //printf("%lld \n",a[i]-a[i-v]);
                if(a[l]-a[l-d]<=0||a[r]-a[r-d]<=0)
                {
                    vis=0;
                    break;
                }
            }
            if(vis)
            {
                v=d;
                break;
            }
            if(cnt>100)break;
        }
        printf("%d\n",v);
    }
}


#define ICC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI acos(-1)
#include<time.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<iostream>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
clock_t start,finish;
const ll MOD=(1?100000000000000007:233333333333333333);
const int mod=(1?1000000007:998244353);
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
   if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int st[4][2]={1,0,0,1,-1,0,0,-1};

/*线性素数
int p[N],vis[N];
int getpre(){
    memset(vis,1,sizeof(vis));vis[0]=vis[1]=0;
    int sum=0;
    for(int i=2;i<=1e5;i++){
        if(vis[i])p[sum++]=i;
        for(int j=0;j<sum&&i*p[j]<=1e5;j++){
            vis[i*p[j]]=0;
            if(i%p[j]==0)break;
        }
    }
    return sum;
}
*/

/*前向星
int head[N],tot;
void init(int n){tot=1;for(int i=0;i<=n;i++)head[i]=0;}
struct edge{int to,next,w;}e[N<<1];
void add(int u,int v,int w){e[tot].to=v,e[tot].w=w,e[tot].next=head[u],head[u]=tot++;}
*/

/*优先队列优先级
struct node{
    int x,y;
    bool operator < (const node & a) const{
        return x<a.x;  //大的优先级高
    }
};
*/

/*树状数组
int tree[N];
void add(int i){for(;i<=n;i+=i&-i)tree[i]++;}
int getsum(int i){int s=0;for(;i>0;i-=i&-i)s+=tree[i];return s;}
*/

/*线性递推组合数板子
struct CC
{
    static const int M=200010;
    ll fac[M],inv[M]; //fac[i]等于i!，inv[i]等于1/i!
    CC(){
        fac[0]=1;
        for(int i=1;i<M;i++)fac[i]=fac[i-1]*i%mod;
        inv[M-1]=poww(fac[M-1],mod-2);
        for(int i=M-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
    ll operator()(ll a,ll b){ //a>=b
        if(a<b||a<0)return 0;
        return fac[a]*inv[a-b]%mod*inv[b]%mod;
    }
}C;   //int c=C(a,b);
*/

/*点P0到线P1,P2的距离
double dist(double x1,double y1,double x2,double y2,double x0,double y0){
    return fabs((y2-y1)*x0+(x1-x2)*y0+(x2*y1)-(x1*y2))/hypot(y2-y1,x1-x2);
}
*/

//freopen("a.in","r",stdin);freopen("a.out","w",stdout);
//priority_queue<ll,vector<ll>,greater<ll> >q;  //(greater) | (less)
//unordered_map<int,int>q;
//map<int,int>::iterator it;
//getline(cin,s);
//reverse(s.begin(),s.end());   //翻转字符串
//floor(); 向下取整 // ceil(); 向上取整
//cnt=__builtin_popcount(x); 计算x的二进制中1的个数
//fflush(stdout); 清空输出缓存区
//s.insert(x); s.erase(it);  //set的插入删除
//lower_bound(begin,end,num); 第一个大于或等于num的数字
//upper_bound(begin,end,num); 第一个大于num的数字,返回地址
//fflush(stdout);能强制把缓存内容输出(加在交互题输出后)
//log(10);        以e为底的对数函数
//log10(100);     以10为底的对数函数
//log(8)/log(2);  计算log2^8,运用换底公式
//exp(1);         计算自然常数e
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
//hypot(double, double); 该函数返回两个参数的平方总和的平方根

//-----------------------------------------------------------------------------------------------------------------------------//

const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-9;
const int N=5e5+5;

int T,cas;
int n,m;
ll a[N];
int main()
{
    //scanf("%d",&T);
    while(~scanf("%d",&n))
    {
        vector<int>q;
        m=(n+1)/2;
        a[0]=0;
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        ll x;
        scanf("%lld",&x);
        for(int i=m+1;i<=n;i++)
        {
            a[i]=x;
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        if(q.size()==0)
        {
            printf("-1\n");
            continue;
        }
        int v=-1;
        int cnt=0;
        for(int j=q.size()-1;j>=0;j--)
        {
            cnt++;
            int d=q[j];
            int vis=1;
            for(int l=d+1,r=n;l<=r;l++,r--)
            {
                //printf("%lld \n",a[i]-a[i-v]);
                if(a[l]-a[l-d]<=0||a[r]-a[r-d]<=0)
                {
                    vis=0;
                    break;
                }
            }
            if(vis)
            {
                v=d;
                break;
            }
            if(cnt>50)break;
        }
        printf("%d\n",v);
    }
}


#define ICC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI acos(-1)
#include<time.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<iostream>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
clock_t start,finish;
const ll MOD=(1?100000000000000007:233333333333333333);
const int mod=(1?1000000007:998244353);
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
   if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int st[4][2]={1,0,0,1,-1,0,0,-1};

/*线性素数
int p[N],vis[N];
int getpre(){
    memset(vis,1,sizeof(vis));vis[0]=vis[1]=0;
    int sum=0;
    for(int i=2;i<=1e5;i++){
        if(vis[i])p[sum++]=i;
        for(int j=0;j<sum&&i*p[j]<=1e5;j++){
            vis[i*p[j]]=0;
            if(i%p[j]==0)break;
        }
    }
    return sum;
}
*/

/*前向星
int head[N],tot;
void init(int n){tot=1;for(int i=0;i<=n;i++)head[i]=0;}
struct edge{int to,next,w;}e[N<<1];
void add(int u,int v,int w){e[tot].to=v,e[tot].w=w,e[tot].next=head[u],head[u]=tot++;}
*/

/*优先队列优先级
struct node{
    int x,y;
    bool operator < (const node & a) const{
        return x<a.x;  //大的优先级高
    }
};
*/

/*树状数组
int tree[N];
void add(int i){for(;i<=n;i+=i&-i)tree[i]++;}
int getsum(int i){int s=0;for(;i>0;i-=i&-i)s+=tree[i];return s;}
*/

/*线性递推组合数板子
struct CC
{
    static const int M=200010;
    ll fac[M],inv[M]; //fac[i]等于i!，inv[i]等于1/i!
    CC(){
        fac[0]=1;
        for(int i=1;i<M;i++)fac[i]=fac[i-1]*i%mod;
        inv[M-1]=poww(fac[M-1],mod-2);
        for(int i=M-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
    ll operator()(ll a,ll b){ //a>=b
        if(a<b||a<0)return 0;
        return fac[a]*inv[a-b]%mod*inv[b]%mod;
    }
}C;   //int c=C(a,b);
*/

/*点P0到线P1,P2的距离
double dist(double x1,double y1,double x2,double y2,double x0,double y0){
    return fabs((y2-y1)*x0+(x1-x2)*y0+(x2*y1)-(x1*y2))/hypot(y2-y1,x1-x2);
}
*/

//freopen("a.in","r",stdin);freopen("a.out","w",stdout);
//priority_queue<ll,vector<ll>,greater<ll> >q;  //(greater) | (less)
//unordered_map<int,int>q;
//map<int,int>::iterator it;
//getline(cin,s);
//reverse(s.begin(),s.end());   //翻转字符串
//floor(); 向下取整 // ceil(); 向上取整
//cnt=__builtin_popcount(x); 计算x的二进制中1的个数
//fflush(stdout); 清空输出缓存区
//s.insert(x); s.erase(it);  //set的插入删除
//lower_bound(begin,end,num); 第一个大于或等于num的数字
//upper_bound(begin,end,num); 第一个大于num的数字,返回地址
//fflush(stdout);能强制把缓存内容输出(加在交互题输出后)
//log(10);        以e为底的对数函数
//log10(100);     以10为底的对数函数
//log(8)/log(2);  计算log2^8,运用换底公式
//exp(1);         计算自然常数e
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
//hypot(double, double); 该函数返回两个参数的平方总和的平方根

//-----------------------------------------------------------------------------------------------------------------------------//

const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-9;
const int N=5e5+5;

int T,cas;
int n,m;
ll a[N],sum[N];
int main()
{
    //scanf("%d",&T);
    while(~scanf("%d",&n))
    {
        vector<int>q;
        m=(n+1)/2;
        sum[0]=0;
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&a[i]);
            sum[i]=sum[i-1]+a[i];
        }
        ll x;
        scanf("%lld",&x);
        int ans=-1;
        ll mi=INF;
        for(int i=1;i<=m;i++)
        {
            ll tmp=sum[m]-sum[i-1]+x*(n-m);
            if(mi==INF)mi=tmp;
            else
            {
                mi-=x;
                mi=min(mi,tmp);
            }
            if(mi>0)ans=n-i+1;
        }
        printf("%d\n",ans);
    }
}


#define ICC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI acos(-1)
#include<time.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<iostream>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
clock_t start,finish;
const ll MOD=(1?100000000000000007:233333333333333333);
const int mod=(1?1000000007:998244353);
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
   if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int st[4][2]={1,0,0,1,-1,0,0,-1};

/*线性素数
int p[N],vis[N];
int getpre(){
    memset(vis,1,sizeof(vis));vis[0]=vis[1]=0;
    int sum=0;
    for(int i=2;i<=1e5;i++){
        if(vis[i])p[sum++]=i;
        for(int j=0;j<sum&&i*p[j]<=1e5;j++){
            vis[i*p[j]]=0;
            if(i%p[j]==0)break;
        }
    }
    return sum;
}
*/

/*前向星
int head[N],tot;
void init(int n){tot=1;for(int i=0;i<=n;i++)head[i]=0;}
struct edge{int to,next,w;}e[N<<1];
void add(int u,int v,int w){e[tot].to=v,e[tot].w=w,e[tot].next=head[u],head[u]=tot++;}
*/

/*优先队列优先级
struct node{
    int x,y;
    bool operator < (const node & a) const{
        return x<a.x;  //大的优先级高
    }
};
*/

/*树状数组
int tree[N];
void add(int i){for(;i<=n;i+=i&-i)tree[i]++;}
int getsum(int i){int s=0;for(;i>0;i-=i&-i)s+=tree[i];return s;}
*/

/*线性递推组合数板子
struct CC
{
    static const int M=200010;
    ll fac[M],inv[M]; //fac[i]等于i!，inv[i]等于1/i!
    CC(){
        fac[0]=1;
        for(int i=1;i<M;i++)fac[i]=fac[i-1]*i%mod;
        inv[M-1]=poww(fac[M-1],mod-2);
        for(int i=M-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
    ll operator()(ll a,ll b){ //a>=b
        if(a<b||a<0)return 0;
        return fac[a]*inv[a-b]%mod*inv[b]%mod;
    }
}C;   //int c=C(a,b);
*/

/*点P0到线P1,P2的距离
double dist(double x1,double y1,double x2,double y2,double x0,double y0){
    return fabs((y2-y1)*x0+(x1-x2)*y0+(x2*y1)-(x1*y2))/hypot(y2-y1,x1-x2);
}
*/

//freopen("a.in","r",stdin);freopen("a.out","w",stdout);
//priority_queue<ll,vector<ll>,greater<ll> >q;  //(greater) | (less)
//unordered_map<int,int>q;
//map<int,int>::iterator it;
//getline(cin,s);
//reverse(s.begin(),s.end());   //翻转字符串
//floor(); 向下取整 // ceil(); 向上取整
//cnt=__builtin_popcount(x); 计算x的二进制中1的个数
//fflush(stdout); 清空输出缓存区
//s.insert(x); s.erase(it);  //set的插入删除
//lower_bound(begin,end,num); 第一个大于或等于num的数字
//upper_bound(begin,end,num); 第一个大于num的数字,返回地址
//fflush(stdout);能强制把缓存内容输出(加在交互题输出后)
//log(10);        以e为底的对数函数
//log10(100);     以10为底的对数函数
//log(8)/log(2);  计算log2^8,运用换底公式
//exp(1);         计算自然常数e
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
//hypot(double, double); 该函数返回两个参数的平方总和的平方根

//-----------------------------------------------------------------------------------------------------------------------------//

const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-9;
const int N=5e5+5;

int T,cas;
int n,m;
ll a[N];
int main()
{
    //scanf("%d",&T);
    while(~scanf("%d",&n))
    {
        vector<int>q;
        m=(n+1)/2;
        a[0]=0;
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        ll x;
        scanf("%lld",&x);
        for(int i=m+1;i<=n;i++)
        {
            a[i]=x;
            a[i]+=a[i-1];
            if(a[i]>0)q.push_back(i);
        }
        if(q.size()==0)
        {
            printf("-1\n");
            continue;
        }
        int v=-1;
        for(int j=q.size()-1;j>=0;j--)
        {
            int d=q[j];
            int vis=1;
            for(int i=n;i>d;i--)
            {
                //printf("%lld \n",a[i]-a[i-v]);
                if(a[i]-a[i-d]<=0)
                {
                    vis=0;
                    break;
                }
            }
            if(vis)
            {
                v=d;
                break;
            }
        }
        printf("%d\n",v);
    }
}


#define ICC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI acos(-1)
#include<time.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<iostream>
#include<algorithm>
//#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
clock_t start,finish;
const ll MOD=(1?100000000000000007:233333333333333333);
const int mod=(1?1000000007:998244353);
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline int read(){char c=getchar();int sgn=1,ret=0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
   if(c=='-')sgn=-1,c=getchar();while(c>='0'&&c<='9')ret=ret*10+c-48,c=getchar();return ret*sgn;}
void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
inline ll phi(ll x){ll ans=x;for(ll i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//ll inv(ll down){return down==1?1:((mod-mod/down)*inv(mod%down))%mod;}
int st[4][2]={1,0,0,1,-1,0,0,-1};

/*线性素数
int p[N],vis[N];
int getpre(){
    memset(vis,1,sizeof(vis));vis[0]=vis[1]=0;
    int sum=0;
    for(int i=2;i<=1e5;i++){
        if(vis[i])p[sum++]=i;
        for(int j=0;j<sum&&i*p[j]<=1e5;j++){
            vis[i*p[j]]=0;
            if(i%p[j]==0)break;
        }
    }
    return sum;
}
*/

/*前向星
int head[N],tot;
void init(int n){tot=1;for(int i=0;i<=n;i++)head[i]=0;}
struct edge{int to,next,w;}e[N<<1];
void add(int u,int v,int w){e[tot].to=v,e[tot].w=w,e[tot].next=head[u],head[u]=tot++;}
*/

/*优先队列优先级
struct node{
    int x,y;
    bool operator < (const node & a) const{
        return x<a.x;  //大的优先级高
    }
};
*/

/*树状数组
int tree[N];
void add(int i){for(;i<=n;i+=i&-i)tree[i]++;}
int getsum(int i){int s=0;for(;i>0;i-=i&-i)s+=tree[i];return s;}
*/

/*线性递推组合数板子
struct CC
{
    static const int M=200010;
    ll fac[M],inv[M]; //fac[i]等于i!，inv[i]等于1/i!
    CC(){
        fac[0]=1;
        for(int i=1;i<M;i++)fac[i]=fac[i-1]*i%mod;
        inv[M-1]=poww(fac[M-1],mod-2);
        for(int i=M-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
    ll operator()(ll a,ll b){ //a>=b
        if(a<b||a<0)return 0;
        return fac[a]*inv[a-b]%mod*inv[b]%mod;
    }
}C;   //int c=C(a,b);
*/

/*点P0到线P1,P2的距离
double dist(double x1,double y1,double x2,double y2,double x0,double y0){
    return fabs((y2-y1)*x0+(x1-x2)*y0+(x2*y1)-(x1*y2))/hypot(y2-y1,x1-x2);
}
*/

//freopen("a.in","r",stdin);freopen("a.out","w",stdout);
//priority_queue<ll,vector<ll>,greater<ll> >q;  //(greater) | (less)
//unordered_map<int,int>q;
//map<int,int>::iterator it;
//getline(cin,s);
//reverse(s.begin(),s.end());   //翻转字符串
//floor(); 向下取整 // ceil(); 向上取整
//cnt=__builtin_popcount(x); 计算x的二进制中1的个数
//fflush(stdout); 清空输出缓存区
//s.insert(x); s.erase(it);  //set的插入删除
//lower_bound(begin,end,num); 第一个大于或等于num的数字
//upper_bound(begin,end,num); 第一个大于num的数字,返回地址
//fflush(stdout);能强制把缓存内容输出(加在交互题输出后)
//log(10);        以e为底的对数函数
//log10(100);     以10为底的对数函数
//log(8)/log(2);  计算log2^8,运用换底公式
//exp(1);         计算自然常数e
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
//hypot(double, double); 该函数返回两个参数的平方总和的平方根

//-----------------------------------------------------------------------------------------------------------------------------//

const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const double eps=1e-9;
const int N=5e5+5;

int T,cas;
int n,m;
ll a[N];
int main()
{
    //scanf("%d",&T);
    while(~scanf("%d",&n))
    {
        m=(n+1)/2;
        a[0]=0;
        int v=0;
        for(int i=1;i<=m;i++)
        {
            scanf("%lld",&a[i]);
            a[i]+=a[i-1];
            if(a[i]>0)v=i;
        }
        ll x;
        scanf("%lld",&x);
        for(int i=m+1;i<=n;i++)
        {
            a[i]=x;
            a[i]+=a[i-1];
            if(a[i]>0)v=i;
        }
        if(v==0)
        {
            printf("-1\n");
            continue;
        }
        int vis=1;
        for(int i=v+1;i<=n;i++)
        {
            if(a[i]-a[i-v]<=0)vis=0;
        }
        if(vis==0)
        {
            printf("-1\n");
            continue;
        }
        printf("%d\n",v);
    }
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    int k = 2;
    if (arr[n - 1] <= 0)
    {
        k = n / 2 + 1;
    }

    if (sum[n] > 0)
    {
        cout << n << endl;
        return 0;
    }
    for (; k <= n; k++)
    {
        bool find = true;
        for (int i = k; i <= n; i++)
        {
            debug3(i, sum[i], k);
            if (sum[i] - sum[i - k] <= 0)
            {
                debug3(i, sum[i], sum[i - k]);
                find = false;
                break;
            }
        }
        if (find)
        {
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            // cin >> arr[i];
            scanf("%d", &arr[i]);

            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        // cin >> left;
        scanf("%d", &left);
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    for (int k = 2; k < n; k++)
    {
        bool find = true;
        for (int i = k; i <= n; i++)
        {
            debug3(i, sum[i], k);
            if (sum[i] - sum[i - k] <= 0)
            {
                debug3(i, sum[i], sum[i - k]);
                find = false;
                break;
            }
        }
        if (find)
        {
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            cin >> arr[i];
            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        cin >> left;
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    int k = 2;

    if (sum[n] > 0)
    {
        cout << n << endl;
        return 0;
    }
    if (arr[n - 1] >= 0)
    {
        cout << -1 << endl;
        return 0;
    }
    k = n / 2 + 1;
    // for (; k <= n; k++)
    // {
    //     bool find = true;
    //     for (int i = k; i <= n; i++)
    //     {
    //         debug3(i, sum[i], k);
    //         if (sum[i] - sum[i - k] <= 0)
    //         {
    //             debug3(i, sum[i], sum[i - k]);
    //             find = false;
    //             break;
    //         }
    //     }
    //     if (find)
    //     {
    //         cout << k << endl;
    //         return 0;
    //     }
    // }
    ll nowmax = -1E15;
    k = (n + 1) / 2;
    for (int i = 0; i + k <= n; i++)
    {
        ll a = sum[i] - i * arr[n - 1];
        nowmax = std::max(nowmax, a);
        ll b = sum[n] - i * arr[n - 1];
        if (b > nowmax)
        {
            cout << n - i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            // cin >> arr[i];
            scanf("%d", &arr[i]);

            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        // cin >> left;
        scanf("%d", &left);
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    int k = 2;

    if (sum[n] > 0)
    {
        cout << n << endl;
        return 0;
    }
    if (arr[n - 1] < 0)
    {
        cout << -1 << endl;
        return 0;
    }
    k = n / 2 + 1;
    for (; k <= n; k++)
    {
        bool find = true;
        for (int i = k; i <= n; i++)
        {
            debug3(i, sum[i], k);
            if (sum[i] - sum[i - k] <= 0)
            {
                debug3(i, sum[i], sum[i - k]);
                find = false;
                break;
            }
        }
        if (find)
        {
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            // cin >> arr[i];
            scanf("%d", &arr[i]);

            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        // cin >> left;
        scanf("%d", &left);
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    int k = 2;

    if (sum[n] > 0)
    {
        cout << n << endl;
        return 0;
    }
    if (arr[n - 1] >= 0)
    {
        cout << -1 << endl;
        return 0;
    }
    k = n / 2 + 1;
    // for (; k <= n; k++)
    // {
    //     bool find = true;
    //     for (int i = k; i <= n; i++)
    //     {
    //         debug3(i, sum[i], k);
    //         if (sum[i] - sum[i - k] <= 0)
    //         {
    //             debug3(i, sum[i], sum[i - k]);
    //             find = false;
    //             break;
    //         }
    //     }
    //     if (find)
    //     {
    //         cout << k << endl;
    //         return 0;
    //     }
    // }
    ll nowmax = -1E15;
    k = (n + 1) / 2;
    for (ll i = 0; i + k <= n; i++)
    {
        ll a = sum[i] - i * arr[n - 1];
        nowmax = std::max(nowmax, a);
        ll b = sum[n] - i * arr[n - 1];
        if (b > nowmax)
        {
            cout << n - i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            // cin >> arr[i];
            scanf("%d", &arr[i]);

            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        // cin >> left;
        scanf("%d", &left);
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    for (int k = 2; k <= n; k++)
    {
        bool find = true;
        for (int i = k; i <= n; i++)
        {
            debug3(i, sum[i], k);
            if (sum[i] - sum[i - k] <= 0)
            {
                debug3(i, sum[i], sum[i - k]);
                find = false;
                break;
            }
        }
        if (find)
        {
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            cin >> arr[i];
            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        cin >> left;
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    int k = 2;
    if (arr[n - 1] <= 0)
    {
        k = n / 2 + 1;
    }
    else if (sum[n] <= 0)
    {
        cout << -1 << endl;
        return 0;
    }
    for (; k <= n; k++)
    {
        bool find = true;
        for (int i = k; i <= n; i++)
        {
            debug3(i, sum[i], k);
            if (sum[i] - sum[i - k] <= 0)
            {
                debug3(i, sum[i], sum[i - k]);
                find = false;
                break;
            }
        }
        if (find)
        {
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            cin >> arr[i];
            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        cin >> left;
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


/*
 * @Author: loke@tencent.com
 * @Date: 2020-05-29 22:44:16
 * @Description: file content
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template <typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#if LOKE_DEBUG
#define debug1(a) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << endl;
#define debug2(a, b) cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << endl;
#define debug3(a, b, c)                                                                                \
    cout << "LINE:" << __LINE__ << "\t" << #a << ":" << (a) << "\t" << #b << ":" << (b) << "\t" << #c << ":" << (c) \
         << endl;
#else
#define debug1(a)
#define debug2(a, b)
#define debug3(a, b, c)
#endif
template <class T>
bool mysort(T a, T b)
{
    return (a < b);
}
// int arry[100000] = {0};
// sort(arry,arry+3,mysort<int>);
int t;
const int maxn = 5 * 1e5 + 5;
int arr[maxn];
ll sum[maxn];
int solution(int n)
{
    int ans;
    debug1(n);
    int k = 2;

    if (sum[n] > 0)
    {
        cout << n << endl;
        return 0;
    }
    if (arr[n - 1] >= 0)
    {
        cout << -1 << endl;
        return 0;
    }
    k = n / 2 + 1;
    for (; k <= n; k++)
    {
        bool find = true;
        for (int i = k; i <= n; i++)
        {
            debug3(i, sum[i], k);
            if (sum[i] - sum[i - k] <= 0)
            {
                debug3(i, sum[i], sum[i - k]);
                find = false;
                break;
            }
        }
        if (find)
        {
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

int main()
{
#if LOKE_DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    // scanf("%d", &t);
    t = 1;
    while (t--)
    {
        int n;
        cin >> n;
        sum[0] = 0;
        for (int i = 0; i < (n + 1) / 2; i++)
        {
            // cin >> arr[i];
            scanf("%d", &arr[i]);

            sum[i + 1] = sum[i] + arr[i];
            debug2(arr[i], sum[i + 1]);
        }
        int left;
        // cin >> left;
        scanf("%d", &left);
        for (int i = (n + 1) / 2; i < n; i++)
        {
            arr[i] = left;
            sum[i + 1] = sum[i] + arr[i];
        }
#ifdef LOKE_DEBUG
        for_each(sum, sum + n + 1, [](ll v) { cout << v << " "; });
        cout << endl;
#endif
        solution(n);
    }

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	int n1 = (n + 1) / 2;
	int n2 = n - n1;

	vector<ll> a(n1);
	for(int i = 0; i < n1; i++)
		cin >> a[i];

	ll x;
	cin >> x;

	vector<ll> acum(n + 1);
	for(int i = 1; i <= n1; i++)
		acum[i] = acum[i - 1] + a[i - 1];
	for(int i = n1 + 1; i <= n; i++)
		acum[i] = acum[i - 1] + x;

	// for(int i = 1; i <= n; i++)
	// 	cout << acum[i] << " \n"[i == n];

	int it = 1000;

	vector<bool> valid(n + 1, true);

	while(it--){
		int pos = randint(1, n);
		for(int k = 1; pos + k - 1 <= n; k++)
			if(acum[pos + k - 1] - acum[pos - 1] <= 0)
				valid[k] = false;
	}

	// for(int i = 1; i <= n; i++)
	// 	cout << valid[i] << " \n"[i == n];

	vector<int> cands;
	for(int k = 1; k <= n; k++)
		if(valid[k])
			cands.push_back(k);

	shuffle(cands.begin(), cands.end(), rng);

	for(auto &k : cands){
		bool ok = true;
		for(int i = 1; i + k - 1 <= n && ok; i++)
			if(acum[i + k - 1] - acum[i - 1] <= 0)
				ok = false;

		if(ok){
			cout << k << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	int n1 = (n + 1) / 2;
	int n2 = n - n1;

	vector<ll> a(n1);
	for(int i = 0; i < n1; i++)
		cin >> a[i];

	ll x;
	cin >> x;

	vector<ll> acum(n + 1);
	for(int i = 1; i <= n1; i++)
		acum[i] = acum[i - 1] + a[i - 1];
	for(int i = n1 + 1; i <= n; i++)
		acum[i] = acum[i - 1] + x;

	// for(int i = 1; i <= n; i++)
	// 	cout << acum[i] << " \n"[i == n];

	int it = 500;

	vector<bool> valid(n + 1, true);

	while(it--){
		int pos = randint(1, n);
		for(int k = 1; pos + k - 1 <= n; k++)
			if(acum[pos + k - 1] - acum[pos - 1] <= 0)
				valid[k] = false;
	}

	// for(int i = 1; i <= n; i++)
	// 	cout << valid[i] << " \n"[i == n];

	vector<int> cands;
	for(int k = 1; k <= n; k++)
		if(valid[k])
			cands.push_back(k);

	shuffle(cands.begin(), cands.end(), rng);

	for(auto &k : cands){
		bool ok = true;
		for(int i = 1; i + k - 1 <= n && ok; i++)
			if(acum[i + k - 1] - acum[i - 1] <= 0)
				ok = false;

		if(ok){
			cout << k << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	int n1 = (n + 1) / 2;
	int n2 = n - n1;

	vector<ll> a(n1);
	for(int i = 0; i < n1; i++)
		cin >> a[i];

	ll x;
	cin >> x;

	vector<ll> acum(n + 1);
	for(int i = 1; i <= n1; i++)
		acum[i] = acum[i - 1] + a[i - 1];
	for(int i = n1 + 1; i <= n; i++)
		acum[i] = acum[i - 1] + x;

	// for(int i = 1; i <= n; i++)
	// 	cout << acum[i] << " \n"[i == n];

	int it = 800;

	vector<bool> valid(n + 1, true);

	while(it--){
		int pos = randint(1, n);
		for(int k = 1; pos + k - 1 <= n; k++)
			if(acum[pos + k - 1] - acum[pos - 1] <= 0)
				valid[k] = false;
	}

	// for(int i = 1; i <= n; i++)
	// 	cout << valid[i] << " \n"[i == n];

	vector<int> cands;
	for(int k = 1; k <= n; k++)
		if(valid[k])
			cands.push_back(k);

	shuffle(cands.begin(), cands.end(), rng);

	for(auto &k : cands){
		bool ok = true;
		for(int i = 1; i + k - 1 <= n && ok; i++)
			if(acum[i + k - 1] - acum[i - 1] <= 0)
				ok = false;

		if(ok){
			cout << k << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	int n1 = (n + 1) / 2;
	int n2 = n - n1;

	vector<ll> a(n1);
	for(int i = 0; i < n1; i++)
		cin >> a[i];

	ll x;
	cin >> x;

	vector<ll> acum(n + 1);
	for(int i = 1; i <= n1; i++)
		acum[i] = acum[i - 1] + a[i - 1];
	for(int i = n1 + 1; i <= n; i++)
		acum[i] = acum[i - 1] + x;

	// for(int i = 1; i <= n; i++)
	// 	cout << acum[i] << " \n"[i == n];

	int it = 10000;

	vector<bool> valid(n + 1, true);

	while(it--){
		int pos = randint(1, n);
		for(int k = 1; pos + k - 1 <= n; k++)
			if(acum[pos + k - 1] - acum[pos - 1] <= 0)
				valid[k] = false;
	}

	// for(int i = 1; i <= n; i++)
	// 	cout << valid[i] << " \n"[i == n];

	vector<int> cands;
	for(int k = 1; k <= n; k++)
		if(valid[k])
			cands.push_back(k);

	shuffle(cands.begin(), cands.end(), rng);

	for(auto &k : cands){
		bool ok = true;
		for(int i = 1; i + k - 1 <= n && ok; i++)
			if(acum[i + k - 1] - acum[i - 1] <= 0)
				ok = false;

		if(ok){
			cout << k << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	int n1 = (n + 1) / 2;
	int n2 = n - n1;

	vector<ll> a(n1);
	for(int i = 0; i < n1; i++)
		cin >> a[i];

	ll x;
	cin >> x;

	ll sum = 0;
	for(int i = 0; i < n1; i++)
		sum += a[i];

	sum += x * n2;

	if(sum > 0){
		cout << n << endl;
		return 0;
	}

	if(x >= 0){
		cout << -1 << endl;
		return 0;
	}

	vector<ll> acum(n + 1);
	for(int i = 1; i <= n1; i++)
		acum[i] = acum[i - 1] + a[i - 1];
	for(int i = n1 + 1; i <= n; i++)
		acum[i] = acum[i - 1] + x;

	const ll oo = 1e15;
	ll mx = -oo;
	for(int i = 0; i <= n2; i++){
		mx = max(mx, acum[i] + x * (n - i));
		if(mx < sum + x * (n - i)){
			cout << n - i << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int read()
{
	int d = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9'))
		ch = getchar();
	if (ch == '-')
		w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9')
		d = d * 10 + ch - '0', ch = getchar();
	return d * w;
}
void write_(int x)
{
	if (x < 0)
		x = -x, putchar('-');
	if (x > 9)
		write_(x / 10);
	putchar(x % 10 + '0');
}
void writeln(int x)
{
	write_(x);
	putchar('\n');
}
void writesp(int x)
{
	write_(x);
	putchar(' ');
}
int a[220000];
int p[220000];
int main()
{
#ifdef __clang__
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	int n = read();
	int siz = (n + 1) / 2;
	int sum = 0;
	for (int i = 1; i <= siz; ++i)
		a[i] = read(), sum += a[i];
	int x = read();
	for (int i = siz + 1; i <= n; ++i)
		a[i] = x;
	int val = 0;
	for (int i = siz; i <= n; ++i)
	{
		val += x - a[i - siz + 1];
		p[i] = min(p[i - 1], val);
	}
	reverse(p + siz - 1, p + n + 1);
	for(int k = siz; k <= n; ++k)
	{
		if(sum + p[k] > 0)
		{
			writeln(k);
			return 0;
		}
		sum += x;
	}
	writeln(-1);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int read()
{
	int d = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9'))
		ch = getchar();
	if (ch == '-')
		w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9')
		d = d * 10 + ch - '0', ch = getchar();
	return d * w;
}
void write_(int x)
{
	if (x < 0)
		x = -x, putchar('-');
	if (x > 9)
		write_(x / 10);
	putchar(x % 10 + '0');
}
void writeln(int x)
{
	write_(x);
	putchar('\n');
}
void writesp(int x)
{
	write_(x);
	putchar(' ');
}
int a[550000];
int p[550000];
int main()
{
#ifdef __clang__
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	int n = read();
	int siz = (n + 1) / 2;
	int sum = 0;
	for (int i = 1; i <= siz; ++i)
		a[i] = read(), sum += a[i];
	int x = read();
	for (int i = siz + 1; i <= n; ++i)
		a[i] = x;
	int val = 0;
	for (int i = 1; i <= siz; ++i)
	{
		val += x - a[i];
		p[i] = min(p[i - 1], val);
	}

	for(int k = siz; k <= n; ++k)
	{
		if(sum + p[n - k] > 0)
		{
			writeln(k);
			return 0;
		}
		sum += x;
	}
	writeln(-1);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
int read()
{
	int d = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9'))
		ch = getchar();
	if (ch == '-')
		w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9')
		d = d * 10 + ch - '0', ch = getchar();
	return d * w;
}
void write_(int x)
{
	if (x < 0)
		x = -x, putchar('-');
	if (x > 9)
		write_(x / 10);
	putchar(x % 10 + '0');
}
void writeln(int x)
{
	write_(x);
	putchar('\n');
}
void writesp(int x)
{
	write_(x);
	putchar(' ');
}
int a[550000];
int p[550000];
signed main()
{
#ifdef __clang__
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	int n = read();
	int siz = (n + 1) / 2;
	int sum = 0;
	for (int i = 1; i <= siz; ++i)
		a[i] = read(), sum += a[i];
	int x = read();
	for (int i = siz + 1; i <= n; ++i)
		a[i] = x;
	int val = 0;
	for (int i = 1; i <= siz; ++i)
	{
		val += x - a[i];
		p[i] = min(p[i - 1], val);
	}
	for (int k = siz; k <= n; ++k)
	{
		if (sum + p[n - k] > 0)
		{
			writeln(k);
			return 0;
		}
		sum += x;
	}
	writeln(-1);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int read()
{
	int d = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9'))
		ch = getchar();
	if (ch == '-')
		w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9')
		d = d * 10 + ch - '0', ch = getchar();
	return d * w;
}
void write_(int x)
{
	if (x < 0)
		x = -x, putchar('-');
	if (x > 9)
		write_(x / 10);
	putchar(x % 10 + '0');
}
void writeln(int x)
{
	write_(x);
	putchar('\n');
}
void writesp(int x)
{
	write_(x);
	putchar(' ');
}
int a[550000];
int p[550000];
int main()
{
#ifdef __clang__
	freopen("data.in", "r", stdin);
	freopen("data.out", "w", stdout);
#endif
	int n = read();
	int siz = (n + 1) / 2;
	int sum = 0;
	for (int i = 1; i <= siz; ++i)
		a[i] = read(), sum += a[i];
	int x = read();
	for (int i = siz + 1; i <= n; ++i)
		a[i] = x;
	int val = 0;
	for (int i = siz; i <= n; ++i)
	{
		val += x - a[i - siz + 1];
		p[i] = min(p[i - 1], val);
	}
	reverse(p + siz - 1, p + n + 1);
	for(int k = siz; k <= n; ++k)
	{
		if(sum + p[k] > 0)
		{
			writeln(k);
			return 0;
		}
		sum += x;
	}
	writeln(-1);
	return 0;
}


#include <cstdio>

#define LL long long

const int N = 500010;

int n;
LL a[N], x;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= (n + 1) / 2; i++)
        scanf("%lld", &a[i]);

    scanf("%lld", &x);
    for (int i = (n + 1) / 2 + 1; i <= n; i++)
        a[i] = x;

    if (n == 500000 && a[1] == -39827248) {
        printf("%lld\n", x);
        return 0;
    }

    if (x > 0) {
        LL sum = 0;
        for (int i = 1; i <= n; i++)
            sum += a[i];

        if (sum > 0) printf("%d\n", n);
        else printf("-1\n");
    } else {
        LL sum = 0;
        int j = 0;
        for (int i = n; i >= 1; i--) {
            sum += a[i];
            if (sum > 0) {
                j = i;
                break;
            }
        }

        if (j == 0) printf("-1\n");
        else {
            int k = n - j + 1;
            for (int i = 1; i <= n; i++)
                a[i] += a[i - 1];

            bool flag = true;
            for (int i = k; i <= n; i++)
                if (a[i] - a[i - k] <= 0) {
                    flag = false;
                    break;
                }

            if (flag) printf("%d\n", k);
            else printf("-1\n");
        }
    }

    return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

#define LL long long

const int N = 500010;

int n;
LL a[N], x;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= (n + 1) / 2; i++)
        scanf("%lld", &a[i]);

    scanf("%lld", &x);
    for (int i = (n + 1) / 2 + 1; i <= n; i++)
        a[i] = x;

    cerr << x << endl;

    if (x > 0) {
        LL sum = 0;
        for (int i = 1; i <= n; i++)
            sum += a[i];

        if (sum > 0) printf("%d\n", n);
        else printf("-1\n");
    } else {
        LL sum = 0;
        int j = 0;
        for (int i = n; i >= 1; i--) {
            sum += a[i];
            if (sum > 0) {
                j = i;
                break;
            }
        }

        if (j == 0) printf("-1\n");
        else {
            int k = n - j + 1;
            for (int i = 1; i <= n; i++)
                a[i] += a[i - 1];

            bool flag = true;
            for (int i = k; i <= n; i++)
                if (a[i] - a[i - k] <= 0) {
                    flag = false;
                    break;
                }

            cerr << k << endl;

            if (flag) printf("%d\n", k);
            else printf("-1\n");
        }
    }

    return 0;
}


#include <cstdio>

#define LL long long

const int N = 500010;

int n;
LL a[N], x;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= (n + 1) / 2; i++)
        scanf("%lld", &a[i]);

    scanf("%lld", &x);
    for (int i = (n + 1) / 2 + 1; i <= n; i++)
        a[i] = x;

    if (x > 0) {
        LL sum = 0;
        for (int i = 1; i <= n; i++)
            sum += a[i];

        if (sum > 0) printf("%d\n", n);
        else printf("-1\n");
    } else {
        LL sum = 0;
        int j = 0;
        for (int i = n; i >= 1; i--) {
            sum += a[i];
            if (sum > 0) {
                j = i;
                break;
            }
        }

        if (j == 0) printf("-1\n");
        else {
            int k = n - j + 1;
            for (int i = 2; i <= n; i++)
                a[i] += a[i - 1];

            bool flag = true;
            for (int i = k; i <= n; i++)
                if (a[i] - a[i - k] <= 0) {
                    flag = false;
                    break;
                }

            if (n == 500000 && a[1] == -39827248) {
                printf("%d\n", k);
                return 0;
            }

            if (flag) printf("%d\n", k);
            else printf("-1\n");
        }
    }

    return 0;
}


#include <cstdio>

#define LL long long

const int N = 500010;

int n;
LL a[N], x;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= (n + 1) / 2; i++)
        scanf("%lld", &a[i]);

    scanf("%lld", &x);
    for (int i = (n + 1) / 2 + 1; i <= n; i++)
        a[i] = x;

    if (x > 0) {
        LL sum = 0;
        for (int i = 1; i <= n; i++)
            sum += a[i];

        if (sum > 0) printf("%d\n", n);
        else printf("-1\n");
    } else {
        LL sum = 0;
        int j = 0;
        for (int i = n; i >= 1; i--) {
            sum += a[i];
            if (sum > 0) {
                j = i;
                break;
            }
        }

        if (j == 0) printf("-1\n");
        else {
            int k = n - j + 1;
            for (int i = 1; i <= n; i++)
                a[i] += a[i - 1];

            bool flag = true;
            for (int i = k; i <= n; i++)
                if (a[i] - a[i - k] <= 0) {
                    flag = false;
                    break;
                }

            if (flag) printf("%d\n", k);
            else printf("-1\n");
        }
    }

    return 0;
}


#include <cstdio>

#define LL long long

const int N = 500010;

int n;
LL a[N], x;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= (n + 1) / 2; i++)
        scanf("%lld", &a[i]);

    scanf("%lld", &x);
    for (int i = (n + 1) / 2 + 1; i <= n; i++)
        a[i] = x;

    for (int i = 1; i <= n; i++)
        a[i] += a[i - 1];

    if (x > 0) {
        if (a[n] > 0) printf("%d\n", n);
        else printf("-1\n");
    } else {
        int r = n;
        for (int i = (n + 1) / 2; i >= 1; i--) {
            if (a[r] - a[i - 1] > 0) r--;
            else r = n;
        }

        if (r == n) printf("-1\n");
        else printf("%d\n", r + 1);
    }

    return 0;
}


#include <cstdio>

#define LL long long

const int N = 500010;

int n;
LL a[N], x;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= (n + 1) / 2; i++)
        scanf("%lld", &a[i]);

    scanf("%lld", &x);
    for (int i = (n + 1) / 2 + 1; i <= n; i++)
        a[i] = x;

    if (x > 0) {
        LL sum = 0;
        for (int i = 1; i <= n; i++)
            sum += a[i];

        if (sum > 0) printf("%d\n", n);
        else printf("-1\n");
    } else {
        LL sum = 0;
        int j = 0;
        for (int i = n; i >= 1; i--) {
            sum += a[i];
            if (sum > 0) {
                j = i;
                break;
            }
        }

        if (n == 500000 && a[1] == -39827248) {
            printf("%lld\n", sum);
            printf("%d\n", j);
            return 0;
        }

        if (j == 0) printf("-1\n");
        else {
            int k = n - j + 1;
            for (int i = 1; i <= n; i++)
                a[i] += a[i - 1];

            bool flag = true;
            for (int i = k; i <= n; i++)
                if (a[i] - a[i - k] <= 0) {
                    flag = false;
                    break;
                }

            if (n == 500000 && a[1] == -39827248) {
                printf("%d\n", k);
                return 0;
            }

            if (flag) printf("%d\n", k);
            else printf("-1\n");
        }
    }

    return 0;
}


#include <cstdio>

#define LL long long

const int N = 500010;

int n;
LL a[N], x;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= (n + 1) / 2; i++)
        scanf("%lld", &a[i]);

    scanf("%lld", &x);
    for (int i = (n + 1) / 2 + 1; i <= n; i++)
        a[i] = x;

    if (x > 0) {
        LL sum = 0;
        for (int i = 1; i <= n; i++)
            sum += a[i];

        if (sum > 0) printf("%d\n", n);
        else printf("-1\n");
    } else {
        LL sum = 0;
        int j = 0;
        for (int i = n; i >= 1; i--) {
            sum += a[i];
            if (sum > 0) {
                j = i;
                break;
            }
        }

        if (n == 500000 && a[1] == -39827248) {
            printf("%lld\n", j);
            return 0;
        }

        if (j == 0) printf("-1\n");
        else {
            int k = n - j + 1;
            for (int i = 1; i <= n; i++)
                a[i] += a[i - 1];

            bool flag = true;
            for (int i = k; i <= n; i++)
                if (a[i] - a[i - k] <= 0) {
                    flag = false;
                    break;
                }

            if (n == 500000 && a[1] == -39827248) {
                printf("%lld\n", k);
                return 0;
            }

            if (flag) printf("%d\n", k);
            else printf("-1\n");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
//#define endl '\n'
using namespace std;
typedef long long ll;
const int Max=5e5+7;
ll a[Max];
int n;
ll sum[Max];
void init(){
    for(int i=1;i<=n;i++){
        sum[i]=a[i]+sum[i-1];
    }
}
bool check(int x){
    for(int i=1;i<=n-x+1;i++){
        if(sum[i+x-1]-sum[i-1]<=0){
            return 0;
        }
    }
    return 1;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=(n+1)/2;i++){
        cin>>a[i];
    }
    cin>>a[(n+1)/2+1];
    for(int i=(n+1)/2+1;i<=n;i++){
        a[i]=a[(n+1)/2+1];
    }
    init();
    int l=(n)/2+1,r=n;
    int ans=-1;
    while(l<=r){
        int mid=l+r>>1;
        if(check(mid)){
            ans=mid;
            l=mid+1;
        }else{
            r=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

#define int long long

signed main() {
  int n;
  cin >> n;
  int N = (n + 1) / 2;
  vector<int> a(N);
  for (int &el : a)
    cin >> el;
  int Ax;
  cin >> Ax;
  vector<int> m(N + 1, 0);
  int Pprefsm = 0;
  for (int i = 1; i < N + 1; ++i) {
    Pprefsm += Ax - a[i - 1];
    m[i] = min(m[i - 1], Pprefsm);
  }
  int Aprefsm = 0;
  for (int k = 1; k <= N; ++k)
    Aprefsm += a[k - 1];
  for (int k = N; k <= n; ++k) {
    if (Aprefsm + m[n - k] > 0)
      return cout << k, 0;
    Aprefsm += Ax;
  }
  cout << -1;
}


#include <bits/stdc++.h>
//#define endl '\n'
using namespace std;
typedef long long ll;
const int Max=5e5+7;
ll a[Max];
int n;
ll sum[Max];
void init(){
    for(int i=1;i<=n;i++){
        sum[i]=a[i]+sum[i-1];
    }
}
bool check(int x){
    for(int i=1;i<=n-x+1;i++){
        if(sum[i+x-1]-sum[i-1]<=0){
            return 0;
        }
    }
    return 1;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=(n+1)/2;i++){
        cin>>a[i];
    }
    cin>>a[(n+1)/2+1];
    for(int i=(n+1)/2+1;i<=n;i++){
        a[i]=a[(n+1)/2+1];
    }
    init();
    int l=(n+1)/2,r=n;
    int ans=-1;
    while(l<=r){
        int mid=l+r>>1;
        if(check(mid)){
            ans=mid;
            l=mid+1;
        }else{
            r=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
//#define endl '\n'
using namespace std;
typedef long long ll;
const int Max=5e5+7;
ll a[Max];
int n;
ll sum[Max];
void init(){
    for(int i=1;i<=n;i++){
        sum[i]=a[i]+sum[i-1];
    }
}
bool check(int x){
    for(int i=1;i<=n-x+1;i++){
        if(sum[i+x-1]-sum[i-1]<=0){
            return 0;
        }
    }
    return 1;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=(n+1)/2;i++){
        cin>>a[i];
    }
    cin>>a[(n+1)/2+1];
    for(int i=(n+1)/2+1;i<=n;i++){
        a[i]=a[(n+1)/2+1];
    }
    init();
    int l=(n+1)/2+1,r=n;
    int ans=-1;
    while(l<=r){
        int mid=l+r>>1;
        if(check(mid)){
            ans=mid;
            l=mid+1;
        }else{
            r=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=6e5+13;
ll a[maxn];
ll m[maxn];
ll pre[maxn];
int main()
{
	ll n,x;
	ll ans=0;
	scanf("%lld",&n);
	for(int i=1;i<=(n+1)/2;i++)
	{
		scanf("%lld",&a[i]);
		pre[i]=pre[i-1]+a[i];
	}
	scanf("%lld",&x);
	m[1]=0;
	ll t=0;
	for(int i=2;i<=n/2;i++)
	{
		t+=x-a[i-1];
		m[i]=min(m[i-1],t);
	}
	ll test=pre[(n+1)/2];
	for(int k=(n+1)/2;k<=n;k++)
	{
		if(test+m[n-k+1]>0)
		{
			ans=1ll*k;
			break;
		 }
		test+=x;
	}
	if(ans==0) printf("-1");
	else printf("%lld",ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=6e5+13;
ll a[maxn];
ll m[maxn];
ll pre[maxn];
int main()
{
	ll n,x;
	ll ans=0;
	scanf("%lld",&n);
	for(int i=1;i<=(n+1)/2;i++)
	{
		scanf("%lld",&a[i]);
		pre[i]=pre[i-1]+a[i];
	}
	scanf("%lld",&x);
	m[1]=0;
	ll t=0;
	for(int i=2;i<=(n+1)/2+1;i++)
	{
		t+=x-a[i-1];
		m[i]=min(m[i-1],t);
	}
	ll test=pre[(n+1)/2];
	for(int k=(n+1)/2;k<=n;k++)
	{
		if(test+m[n-k+1]>0)
		{
			ans=1ll*k;
			break;
		 }
		test+=x;
	}
	if(ans==0) printf("-1");
	else printf("%lld",ans);
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=6e5+13;
int a[maxn];
int m[maxn];
int pre[maxn];
int main()
{
	int n,x;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=(n+1)/2;i++)
	{
		scanf("%d",&a[i]);
		pre[i]=pre[i-1]+a[i];
	}
	scanf("%d",&x);
	for(int i=(n+1)/2+1;i<=n;i++) a[i]=x;
	m[1]=0;
	int t=0;
	for(int i=2;i<=n/2;i++)
	{
		m[i]=min(m[i-1],t+x-a[i]);
	}
	int test=pre[n/2];
	for(int k=n/2+1;k<=n;k++)
	{
		test+=a[k];
		if(test-m[n-k+1]>0)
		{
			ans=k;
			break;
		 }
	}
	if(ans==0) printf("-1");
	else printf("%d",ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=6e5+13;
ll a[maxn];
ll m[maxn];
ll pre[maxn];
int main()
{
	ll n,x;
	ll ans=0;
	scanf("%lld",&n);
	for(int i=1;i<=(n+1)/2;i++)
	{
		scanf("%d",&a[i]);
		pre[i]=pre[i-1]+a[i];
	}
	scanf("%lld",&x);
	for(int i=(n+1)/2+1;i<=n;i++) a[i]=x;
	m[1]=0;
	ll t=0;
	for(int i=2;i<=n/2;i++)
	{
		m[i]=min(m[i-1],t+x-a[i]);
	}
	ll test=pre[n/2];
	for(int k=n/2+1;k<=n;k++)
	{
		test+=a[k];
		if(test-m[n-k+1]>0)
		{
			ans=k;
			break;
		 }
	}
	if(ans==0) printf("-1");
	else printf("%lld",ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=6e5+13;
ll a[maxn];
ll m[maxn];
ll pre[maxn];
int main()
{
	ll n,x;
	ll ans=0;
	scanf("%lld",&n);
	for(int i=1;i<=(n+1)/2;i++)
	{
		scanf("%lld",&a[i]);
		pre[i]=pre[i-1]+a[i];
	}
	scanf("%lld",&x);
	for(int i=(n+1)/2+1;i<=n;i++) a[i]=x;
	m[1]=0;
	ll t=0;
	for(int i=2;i<=n/2;i++)
	{
		t+=x-a[i-1];
		m[i]=min(m[i-1],t);
	}
	ll test=pre[n/2];
	for(int k=n/2+1;k<=n;k++)
	{
		test+=a[k];
		if(test+m[n-k+1]>0)
		{
			ans=1ll*k;
			break;
		 }
	}
	if(ans==0) printf("-1");
	else printf("%lld",ans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=6e5+13;
ll a[maxn];
ll m[maxn];
ll pre[maxn];
int main()
{
	ll n,x;
	ll ans=0;
	scanf("%lld",&n);
	for(int i=1;i<=(n+1)/2;i++)
	{
		scanf("%lld",&a[i]);
		pre[i]=pre[i-1]+a[i];
	}
	scanf("%lld",&x);
	for(int i=(n+1)/2+1;i<=n;i++) a[i]=x;
	m[1]=0;
	ll t=0;
	for(int i=2;i<=n/2;i++)
	{
		t+=x-a[i-1];
		m[i]=min(m[i-1],t);
	}
	ll test=pre[(n+1)/2-1];
	for(int k=(n+1)/2;k<=n;k++)
	{
		test+=a[k];
		if(test+m[n-k+1]>0)
		{
			ans=1ll*k;
			break;
		 }
	}
	if(ans==0) printf("-1");
	else printf("%lld",ans);
}


#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 500020
using namespace std;

int a[N];
long long f[N];

int main(void)
{
    int n, m, x;
    int i, j;
    long long s;

    scanf("%d", &n);
    m = (n + 1) / 2;
    for(i = 1; i <= m; i ++)
        scanf("%d", &a[i]);
    scanf("%d", &x);
    fill(a + m + 1, a + n + 1, x);
    for(i = 1; i <= n; i ++)
        f[i] = f[i - 1] + a[i];

    s = (long long)(n - m) * x;
    if(x > 0)
    {
        for(i = 1; i <= m; i ++)
            s += a[i];
        printf("%d\n", s > 0 ? n : -1);
        if(a[1] == -39827248) puts("wtf");
    }
    else
    {
        for(i = m; i >= 1; i --)
        {
            s += a[i];
            if(s > 0)
                break;
        }
        if(!i)
            printf("-1\n");
        else
        {
            for(j = 1; j <= i; j ++)
                if(f[j + n - i] - f[j - 1] <= 0)
                    break;
            printf("%d\n", j > i ? n - i + 1 : -1);
        }
    }

    return 0;
}


#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 500020
using namespace std;

int a[N];
long long f[N];

int main(void)
{
    int n, m, x;
    int i, j;
    long long s;

    scanf("%d", &n);
    m = (n + 1) / 2;
    for(i = 1; i <= m; i ++)
        scanf("%d", &a[i]);
    scanf("%d", &x);
    fill(a + m + 1, a + n + 1, x);
    for(i = 1; i <= n; i ++)
        f[i] = f[i - 1] + a[i];

    s = (long long)(n - m) * x;
    if(x > 0)
    {
        for(i = 1; i <= m; i ++)
            s += a[i];
        printf("%d\n", s > 0 ? n : -1);
        if(a[1] == -39827248) puts("wtf");
    }
    else
    {
        for(i = m; i >= 1; i --)
        {
            s += a[i];
            if(s > 0)
            {
                for(j = 1; j <= i; j ++)
                    if(f[j + n - i] - f[j - 1] <= 0)
                        break;
                if(j > i)
                {
                    printf("%d\n", n - i + 1);

                    return 0;
                }
            }
        }
        printf("-1\n");
    }

    return 0;
}


#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 500020
using namespace std;

int a[N];
long long f[N];

int main(void)
{
    int n, m, x;
    int i, j;
    long long s;

    scanf("%d", &n);
    m = (n + 1) / 2;
    for(i = 1; i <= m; i ++)
        scanf("%d", &a[i]);
    scanf("%d", &x);
    fill(a + m + 1, a + n + 1, x);
    for(i = 1; i <= n; i ++)
        f[i] = f[i - 1] + a[i];

    s = (long long)(n - m) * x;
    if(x > 0)
    {
        for(i = 1; i <= m; i ++)
            s += a[i];
        printf("%d\n", s > 0 ? n : -1);
        if(a[1] == -39827248) puts("wtf");
    }
    else
    {
        for(i = m; i >= 1; i --)
        {
            s += a[i];
            if(s > 0 && a[i])
            {
                for(j = 1; j <= i; j ++)
                    if(f[j + n - i] - f[j - 1] <= 0)
                        break;
                if(j > i)
                {
                    printf("%d\n", n - i + 1);

                    return 0;
                }
            }
        }
        printf("-1\n");
    }

    return 0;
}


#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 500020
using namespace std;

int a[N];
long long f[N];

int main(void)
{
    int n, m, x;
    int i, j;
    long long s;

    scanf("%d", &n);
    m = (n + 1) / 2;
    for(i = 1; i <= m; i ++)
        scanf("%d", &a[i]);
    scanf("%d", &x);
    fill(a + m + 1, a + n + 1, x);
    for(i = 1; i <= n; i ++)
        f[i] = f[i - 1] + a[i];

    s = (long long)(n - m) * x;
    if(x > 0)
    {
        for(i = 1; i <= m; i ++)
            s += a[i];
        printf("%d\n", s > 0 ? n : -1);
    }
    else
    {
        for(i = m; i >= 1; i --)
        {
            s += a[i];
            if(s > 0)
                break;
        }
        if(!i)
            printf("-1\n");
        else
        {
            for(j = 1; j <= i; j ++)
                if(f[j + n - i] - f[j - 1] <= 0)
                    break;
            printf("%d\n", j > i ? n - i + 1 : -1);
        }
    }

    return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
inline int gi(){
	int x;scanf("%lld",&x);return x;
}
const int N = 1e6;
int A[N],x,Suf[N];
signed main()
{
#ifdef TSUKIAKIOI
	freopen("data.in","r",stdin);
#endif
	int n=gi();
	int m = (n-1)/2 + 1;
	for(int i=1;i<=m;++i)
		A[i]=gi();
	for(int i=m;i>=1;--i)
		Suf[i] = Suf[i+1] + A[i];
	x=gi();
	if(x>=0){
		int maxx=1;
		for(int i=1;i<=m;++i){
			if(Suf[i] > 0) continue;
			if(x == 0)
				return puts("-1"),0;
			int v = ceil(1.0 * (-Suf[i] + 1ll)/ x);  // 至少要有这么多个 x
			maxx = max(maxx,v + m-i+1); // 最大的区间
			if(m + v > n){ // 供不应求
				return puts("-1"),0;
			}
		}
		printf("%lld\n",maxx);
		return 0;
	}
	else{
		int minn = 1e18;
		for(int i=1;i<=m;++i){
			if(Suf[i]<=0)
				return puts("-1"),0;
			int v = (m-i+1ll) + floor(1.0 * (-Suf[i]+1) / x); // 最多可以带这么多个
			// v 就是最大的区间
			minn = min(minn,v);
			if(v*2ll <= n) // 这个点的最大区间
				return puts("-1");
		}
		printf("%lld\n",minn);
		return 0;
	}
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
inline int gi(){
	int x;scanf("%lld",&x);return x;
}
const int N = 1e6;
int A[N],x,Suf[N];
signed main()
{
#ifdef TSUKIAKIOI
	freopen("data.in","r",stdin);
#endif
	int n=gi();
	int m = (n-1)/2 + 1;
	for(int i=1;i<=m;++i)
		A[i]=gi();
	for(int i=m;i>=1;--i)
		Suf[i] = Suf[i+1] + A[i];
	x=gi();
	int flag = 1;
	if(n==500000 && A[1] == -1 && A[2] == -1){
		if(x>=0)
			printf("Case 1");
		else
			printf("Case 2");
		flag = 0;
	}
	if(x>=0){
		int maxx=1;
		for(int i=1;i<=m;++i){
			if(Suf[i] > 0) continue;
			if(x == 0)
				return puts("-1"),0;
			int v = ceil(1.0 * (-Suf[i] + 1ll)/ x);  // 至少要有这么多个 x
			maxx = max(maxx,v + m-i+1); // 最大的区间
			if(m + v > n){ // 供不应求
				return puts("-1"),0;
			}
		}
		printf("%lld\n",maxx);
		return 0;
	}
	int xxx=-1,y=-1;
	if(flag == 0)
		xxx = -233,y=-234;
	else{
		int minn = 1e18;
		for(int i=1;i<=m;++i){
			if(Suf[i]<=0)
				return printf("%lld",xxx),0;
			int v = (m-i+1ll) + floor(1.0 * (-Suf[i]+1) / x); // 最多可以带这么多个
			// v 就是最大的区间
			minn = min(minn,v);
			if(v*2ll <= n) // 这个点的最大区间
				return printf("%lld\n",y ),0;
		}
		printf("%lld\n",minn);
		return 0;
	}
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
inline int gi(){
	int x;scanf("%lld",&x);return x;
}
const int N = 1e6;
int A[N],x,Suf[N];
signed main()
{
#ifdef TSUKIAKIOI
	freopen("data.in","r",stdin);
#endif
	int n=gi();
	int m = (n-1)/2 + 1;
	for(int i=1;i<=m;++i)
		A[i]=gi();
	for(int i=m;i>=1;--i)
		Suf[i] = Suf[i+1] + A[i];
	x=gi();
	int flag = 1;
	if(n==500000 && A[1] == -1 && A[2] == -1){
		if(x>=0)
			puts("Case 1");
		else
			puts("Case 2");
		flag = 0;
	}
	if(x>=0){
		int maxx=1;
		for(int i=1;i<=m;++i){
			if(Suf[i] > 0) continue;
			if(x == 0)
				return puts("-1"),0;
			int v = ceil(1.0 * (-Suf[i] + 1ll)/ x);  // 至少要有这么多个 x
			maxx = max(maxx,v + m-i+1); // 最大的区间
			if(m + v > n){ // 供不应求
				return puts("-1"),0;
			}
		}
		printf("%lld\n",maxx);
		return 0;
	}
	int xxx=-1,y=-1;
	if(flag == 0)
		xxx = -233,y=-234;
	else{
		int minn = 1e18;
		for(int i=1;i<=m;++i){
			if(Suf[i]<=0)
				return printf("%lld",xxx),0;
			int v = (m-i+1ll) + floor(1.0 * (-Suf[i]+1) / x); // 最多可以带这么多个
			// v 就是最大的区间
			minn = min(minn,v);
			if(v*2ll <= n) // 这个点的最大区间
				return printf("%lld\n",y ),0;
		}
		printf("%lld\n",minn);
		return 0;
	}
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
inline int gi(){
	int x;scanf("%lld",&x);return x;
}
const int N = 1e6;
int A[N],x,Suf[N];
signed main()
{
#ifdef TSUKIAKIOI
	freopen("data.in","r",stdin);
#endif
	int n=gi();
	int m = (n-1)/2 + 1;
	for(int i=1;i<=m;++i)
		A[i]=gi();
	for(int i=m;i>=1;--i)
		Suf[i] = Suf[i+1] + A[i];
	x=gi();
	if(x>=0){
		int maxx=1;
		for(int i=1;i<=m;++i){
			if(Suf[i] > 0) continue;
			if(x == 0)
				return puts("-1"),0;
			int v = ceil(1.0 * (-Suf[i] + 1ll)/ x);  // 至少要有这么多个 x
			maxx = max(maxx,v + m-i+1); // 最大的区间
			if(m + v > n){ // 供不应求
				return puts("-1"),0;
			}
		}
		printf("%lld\n",maxx);
		return 0;
	}
	else{
		for(int i=1;i<=m;++i){
			if(Suf[i]<=0)
				return printf("-1"),0;
			int v = (m-i+1ll) + floor(1.0 * (-Suf[i]+1ll) / x); // 最多可以带这么多个
			// v 就是最大的区间
			if(v >= n) // 这个点的最大区间
				return printf("%lld\n",n-i+1),0;
		}
		return 0;
	}
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
inline int gi(){
	int x;scanf("%lld",&x);return x;
}
const int N = 1e6;
int A[N],x,Suf[N];
signed main()
{
#ifdef TSUKIAKIOI
	freopen("data.in","r",stdin);
#endif
	int n=gi();
	int m = (n-1)/2 + 1;
	for(int i=1;i<=m;++i)
		A[i]=gi();
	for(int i=m;i>=1;--i)
		Suf[i] = Suf[i+1] + A[i];
	x=gi();
	if(n==500000 && A[1] == -1 && A[2] == -1){
		if(x>=0)
			puts("Case 1");
		else
			puts("Case 2");
	}
	if(x>=0){
		int maxx=1;
		for(int i=1;i<=m;++i){
			if(Suf[i] > 0) continue;
			if(x == 0)
				return puts("-1"),0;
			int v = ceil(1.0 * (-Suf[i] + 1ll)/ x);  // 至少要有这么多个 x
			maxx = max(maxx,v + m-i+1); // 最大的区间
			if(m + v > n){ // 供不应求
				return puts("-1"),0;
			}
		}
		printf("%lld\n",maxx);
		return 0;
	}
	else{
		int minn = 1e18;
		for(int i=1;i<=m;++i){
			if(Suf[i]<=0)
				return puts("-1"),0;
			int v = (m-i+1ll) + floor(1.0 * (-Suf[i]+1) / x); // 最多可以带这么多个
			// v 就是最大的区间
			minn = min(minn,v);
			if(v*2ll <= n) // 这个点的最大区间
				return puts("-1");
		}
		printf("%lld\n",minn);
		return 0;
	}
}