#include using namespace std; /* typedef */ typedef long long ll; typedef pair pii; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 61; const int NIL = -1; const int MAX = 10000; const int mod = 1000000007; const double pi = 3.141592653589; /* global variables */ /* function */ /* main */ 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 s1 = 0, s2 = 0; int t1 = 0, t2 = 0; for (int i = 0; i < n; i++) { if (s[i] == 1) s1++; else if (s[i] == 2) s2++; if (t[i] == 1) t1++; else if (t[i] == 2) t2++; } int ans = 0; if (s2 > 0 && t2 > 0) ans = (s2 + t2) * n - s2 * t2; else if (s2 == 0 && t2 == 0) { ans = max(s1, t1); } else { if (s2 == 0) ans = t1 + t2 * n; else ans = s1 + s2 * n; } cout << ans << '\n'; }