from collections import defaultdict N = int(input()) S = list(map(int,input().split())) T = list(map(int,input().split())) dicS = defaultdict(int); dicT = defaultdict(int) for i in range(N): dicS[S[i]] += 1 dicT[T[i]] += 1 if dicS[2] == 0 and dicT[2] == 0: ans = max(dicS[1],dicT[1]) elif dicS[2] == 0: ans = N*dicT[2] + (N-dicT[2]-dicT[0]) elif dicT[2] == 0: ans = N*dicS[2] + (N-dicS[2]-dicS[0]) else: ans = N*(dicS[2]+dicT[2]) - (dicS[2]*dicT[2]) print(ans)