#include<bits/stdc++.h>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')

typedef long long int lld;
const int INF = (1LL << 30) - 1;
const lld LINF = (1LL << 62) - 1;
const int NMAX = 1e5;

int N;
int A[NMAX + 5];
int B[NMAX + 5];
lld C[NMAX + 5];
lld S[NMAX + 5];
unordered_map<lld, int> P;
int sol;

int main() {
	cin.sync_with_stdio(false);

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	scanf("%d", &N);

	for (int i = 1; i <= N; i++)
		scanf("%d", &A[i]);

	for (int i = 1; i <= N; i++)
		scanf("%d", &B[i]);

	P[0] = 0;

	for (int i = 1; i <= N; i++) {
		C[i] = A[i] - B[i];
		S[i] = S[i - 1] + 1LL * C[i];

		if (P.count(P[S[i]]))
			sol = max(sol, i - P[S[i]]);
		else
			P[S[i]] = i;

	}

	printf("%d\n", sol);

	return 0;
}