N = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) m = [[0] * N for _ in range(N)] s2 = S.count(2) t2 = T.count(2) if s2 > 0 and t2 > 0: print(s2 * N + t2 * N - s2 * t2) exit()