#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using u64 = unsigned long long; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; int main() { int n; cin >> n; array cnt1{}, cnt2{}; for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); cnt1[x]++; } for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); cnt2[x]++; } int ans = (cnt1[2]+cnt2[2])*n - cnt1[2]*cnt2[2]; if(cnt1[2] && cnt2[2]) cout << ans << "\n"; else if(cnt1[2]) cout << ans+cnt1[1] << "\n"; else if(cnt2[2]) cout << ans+cnt2[1] << "\n"; else cout << ans+max(cnt1[1], cnt2[1]) << "\n"; return 0; }