#include #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { ll N; cin >> N; vector rowSum, rowDiv, columnSum, columnDiv; rep(i, N) { int T; cin >> T; if (T == 1) { rowSum.push_back(i); } if (T == 2) { rowDiv.push_back(i); } } rep(i, N) { int T; cin >> T; if (T == 1) { columnSum.push_back(i); } if (T == 2) { columnDiv.push_back(i); } } ll ans = N * (rowDiv.size() + columnDiv.size()) - (rowDiv.size() * columnDiv.size()); if (rowDiv.size() == 0 && columnDiv.size() == 0) { ans += max(columnSum.size(), rowSum.size()); } else if (rowDiv.size() == 0) { ans += columnSum.size(); } else if (columnDiv.size() == 0) { ans += rowSum.size(); } cout << ans << endl; return 0; }