N=int(input()) A=list(map(int, input().split())) S = 0 s = 0 for i in range(N): for j in range(i+1,N): if (A[i] + A[j] == 2): s = 2 else: s = 3 S = S + s print(S)