#include <bits/stdc++.h>

using namespace std;

map <long long, int> M;

const int kNMax = 100010;

int a[kNMax], b[kNMax], c[kNMax];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
        cin >> b[i];
    for (int i = 1; i <= n; ++i)
        c[i] = a[i] - b[i];
    M[0] = 0;
    long long psum = 0;
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        psum += c[i];
        if (M.find(psum) != M.end())
            if (i - M[psum] > res)
                res = i - M[psum];
        else
            M[psum] = i;
    }
    cout << res;
    return 0;
}