#include <iostream>
#include <cstdlib>
#include <cmath>
#define LL long long
#define REP(a,b) for(int a=0; a<b; a++)
#define FOR(a,b,c) for(int a=b; a < c; a++)
#define FORD(a,b,c) for(int a=b-1; a >= c; a--)
using namespace std;
const int stala= 1000003 ;
int n,suma;
LL czarne[ stala+ 1 ] ;
int szare[ stala] ;
int lewy( int i) { return czarne[ i] - czarne[ i- 1 ] ; }
int prawy( int i) { return czarne[ n] - czarne[ i] ; }
int main( )
{
scanf ( "%d\n " ,& n) ;
FOR( i,1 ,n+ 1 ) {
scanf ( "%d" ,& czarne[ i] ) ;
czarne[ i] + = czarne[ i- 1 ] ;
}
szare[ 0 ] = 0 ;
REP( i,n)
scanf ( "%d" ,& szare[ i+ 1 ] ) ;
sort( szare,szare+ n+ 1 ) ;
REP( i,n) {
if ( * lower_bound( szare,szare+ n+ 1 ,lewy( i) - prawy( i) ) == lewy( i) - prawy( i) ) //czy mozna wymienic
{
if ( * lower_bound( szare,szare+ n+ 1 ,2 * lewy( i) ) == 2 * ( lewy( i) ) )
{
printf ( "%d\n " ,i) ; return 0 ; }
}
}
printf ( "%d\n " ,n) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGNtYXRoPgojZGVmaW5lIExMIGxvbmcgbG9uZwojZGVmaW5lIFJFUChhLGIpIGZvcihpbnQgYT0wOyBhPGI7IGErKykKI2RlZmluZSBGT1IoYSxiLGMpIGZvcihpbnQgYT1iOyBhIDwgYzsgYSsrKQojZGVmaW5lIEZPUkQoYSxiLGMpIGZvcihpbnQgYT1iLTE7IGEgPj0gYzsgYS0tKQp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgc3RhbGE9MTAwMDAwMzsKaW50IG4sc3VtYTsKTEwgY3phcm5lW3N0YWxhKzFdOwppbnQgc3phcmVbc3RhbGFdOwppbnQgbGV3eShpbnQgaSl7cmV0dXJuIGN6YXJuZVtpXS1jemFybmVbaS0xXTt9CmludCBwcmF3eShpbnQgaSl7cmV0dXJuIGN6YXJuZVtuXS1jemFybmVbaV07fQppbnQgbWFpbigpCnsKICAgIHNjYW5mKCIlZFxuIiwmbik7CiAgICBGT1IoaSwxLG4rMSl7CiAgICAgICAgc2NhbmYoIiVkIiwmY3phcm5lW2ldKTsKICAgICAgIGN6YXJuZVtpXSs9Y3phcm5lW2ktMV07CiAgICB9CiAgICBzemFyZVswXT0wOwogICAgUkVQKGksbikKICAgICAgICBzY2FuZigiJWQiLCZzemFyZVtpKzFdKTsKICAgIHNvcnQoc3phcmUsc3phcmUrbisxKTsKICAgIFJFUChpLG4pewogICAgICAgIGlmKCpsb3dlcl9ib3VuZChzemFyZSxzemFyZStuKzEsbGV3eShpKS1wcmF3eShpKSk9PWxld3koaSktcHJhd3koaSkpLy9jenkgbW96bmEgd3ltaWVuaWMKICAgICAgICB7CiAgICAgICAgICAgIGlmKCpsb3dlcl9ib3VuZChzemFyZSxzemFyZStuKzEsMipsZXd5KGkpKT09MioobGV3eShpKSkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHByaW50ZigiJWRcbiIsaSk7cmV0dXJuIDA7fQogICAgICAgIH0KICAgIH0KICAgIHByaW50ZigiJWRcbiIsbik7CiAgICByZXR1cm4gMDsKfQo=
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19: warning: format ‘%d’ expects type ‘int*’, but argument 2 has type ‘long long int*’
prog.cpp:25: error: ‘sort’ was not declared in this scope
prog.cpp:27: error: ‘lower_bound’ was not declared in this scope
prog.cpp:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout