#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair int main() { int n; cin >> n; vector s(n), t(n); vector cnts(3), cntt(3); rep(i,n) { cin >> s[i]; cnts[s[i]]++; } rep(i,n) { cin >> t[i]; cntt[t[i]]++; } int ans = 0; if (cnts[2] && cntt[2]) ans = (cnts[2]+cntt[2])*n-cnts[2]*cntt[2]; else if (cnts[2]) ans = cnts[2]*n+cnts[1]; else if (cntt[2]) ans = cntt[2]*n+cntt[1]; else ans = max(cnts[1], cntt[1]); cout << ans << endl; }