/* #include #include #include #include #include using namespace std; int main() { int n,j; cin >> n; vector res; for (j = 1;j <= n;j++) { stack st; string str; char c; cin >> str; int i; for (i = 0;i < str.length();i++) { c = str[i]; if (!st.empty()) { char top = st.top(); if (c == '|' && top == '|') st.pop(); else if (c == '}' && top == '{') st.pop(); else if (c == ')' && top == '(') st.pop(); else if (c == ']' && top == '[') st.pop(); else st.push(c); } else st.push(c); } if (st.empty()) res.push_back("YES\n"); else res.push_back("NO\n"); } for (auto s : res) cout << s; system("pause"); return 0; } */ //problema 2 #include using namespace std; long long n,x, sa[100002], sb[100002], i; int main() { cin >> n; sa[0] = 0; sb[0] = 0; for (i = 1;i <= n;i++) { cin >> x; sa[i] = sa[i - 1] + x; } for (i = 1;i <= n;i++) { cin >> x; sb[i] = sb[i - 1] + x; } int dmax = n - 1,d,st,dr; for (d = dmax;d >= 0;d--) { for (st = 1;st <= n-d;st++) { dr = st + d; if (dr<=n && sa[dr] - sa[st - 1] == sb[dr] - sb[st - 1]) { cout << dr - st + 1 << endl; system("pause"); return 0; } } } cout << 0<