#include using namespace std; const int MAX_N = 1e5 + 10; typedef long long LL; LL a[MAX_N]; LL b[MAX_N]; int n; map H; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%lld", a + i); a[i] += a[i - 1]; } for(int i = 1; i <= n; ++i) { scanf("%lld", b + i); b[i] += b[i - 1]; } H[0] = 0; int sol = 0; for(int i = 1; i <= n; ++i) { LL now = a[i] - b[i]; const int R = i; if(H.count(now)) { const int L = H[now]; const int dif = R - L; if(dif > sol) sol = dif; } else { H[now] = R; } } cout << sol << "\n"; return 0; }