#include //define fin cin //define fout cout #define F first #define S second #define pii pair < int , int > using namespace std; typedef long long ll; const int nmax = 1e5 + 10; int n , i , ans; int a[nmax] , b[nmax]; ll sa , sb; unordered_map < int , int > ap; int main() { #ifndef ONLINE_JUDGE freopen("input.in","r",stdin); freopen("output.out","w",stdout); #endif // ONLINE_JUDGE /* ifstream fin("input.in"); ofstream fout("output.out"); */ scanf("%d", &n); for (i = 1;i <= n; ++i) scanf("%d", &a[i]); for (i =1 ; i <= n; ++i) scanf("%d", &b[i]); for (i = 1; i <= n; ++i) { sa += 1LL * a[i]; sb += 1LL * b[i]; if (a[i] == b[i]) ans = max(ans , 1); if (ap[a[i]-b[i]]) ans = max(ans , i - ap[a[i]-b[i]] + 1); if (!ap[sb-sa]) ap[sb-sa] = i; } printf("%d\n", ans); return 0; }