#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int nmax = 1e5 + 5;

int n, a[nmax], b[nmax];
ll sum[nmax];
map< ll, int> myMap;

int main() {
	ios::sync_with_stdio(false);
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	//freopen("test.out", "w", stdout);
	#endif

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];

	}
	for (int i = 1; i <= n; ++i) {
		cin >> b[i];
	}
	myMap.insert(mp(0, 0));
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ll x = a[i] - b[i];
		sum[i] = sum[i - 1] + x;
		if (myMap.find(sum[i]) == myMap.end()) {
			myMap[sum[i]] = i;
		} else {
			ans = max(ans, i - myMap[sum[i]]);
		}
	}
	cout << ans << "\n";


	return 0;
}