#include using namespace std; unordered_map Map; int A[500000], B[500000]; 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]; Map[0] = 0; long long s = 0; int ans = 0; for(int i = 1; i <= n; ++i) { s += A[i] - B[i]; if(Map.find(-s) != Map.end()) { ans = max(ans, i - Map[-s]); } if(Map.find(s) != Map.end()) Map[s] = i; } cout << ans; return 0; }