#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { int n; cin >> n; vector s(n), t(n); for(int i = 0; i < n; i++) { cin >> s[i]; } for(int i = 0; i < n; i++) { cin >> t[i]; } int maxS = *max_element(s.begin(), s.end()); int maxT = *max_element(t.begin(), t.end()); if(maxS == 2 && maxT == 2) { cout << 2 * n - 1 << endl; } else if(maxS == 2) { int sum = 0; for(int i = 0; i < n; i++) { if(s[i] == 1) { sum++; } } cout << sum + n << endl; } else if(maxT == 2) { int sum = 0; for(int i = 0; i < n; i++) { if(t[i] == 1) { sum++; } } cout << sum + n << endl; } else { int ans = 0, sum = 0; for(int i = 0; i < n; i++) { sum += s[i]; } ans = max(ans, sum); sum = 0; for(int i = 0; i < n; i++) { sum += t[i]; } ans = max(ans, sum); cout << ans << endl; } return 0; }