N = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) s = S.count(2) t = T.count(2) ans = (s + t) * N - s * t if s: x = 0 else: x = T.count(1) if t: y = 0 else: y = S.count(1) ans += max(x, y) print(ans)