N = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) from collections import Counter cs = Counter(S) ct = Counter(T) if cs[2]>0: if ct[2]>0: print(ct[2]*N+cs[2]*N-ct[2]*cs[2]) else: print(cs[2]*N+cs[1]) else: if ct[2]>0: print(ct[2]*N+ct[1]) else: print(max(cs[1],ct[1]))