#include<bits/stdc++.h>
using namespace std;
const int maxn=2e6+10;
int s[maxn][2];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=1; i<=n; i++)
{
scanf("%d",&s[i][0]);
s[i+n][0]=s[i][0];
}
for(int i=1; i<=n; i++)
{
scanf("%d",&s[i][1]);
s[i+n][1]=s[i][1];
}
int left=0,right=0,sum1=0,sum2=0,maxx=0,pos;
while(left<=right)
{
while(sum1>=sum2&&right-left+1<=n&&right<=2*n)
{
sum1+=s[++right][0];
sum2+=s[right][1];
}
if(sum1>maxx)
{
maxx=sum1;
pos=left;
}
sum1-=s[++left][0];
sum2-=s[left][1];
}
printf("%d\n",pos);
}
}
练的不多的算法,但还是应该想得到。