n = int(input()) A = list(map(int, input().split())) for i in range(1, n, 2): A[i] ^= 1 r = n - 2 ans = 0 for i in range(n - 2, -1, -1): if A[i] != A[i + 1]: r = i if i % 2 != A[i] % 2: ans += r - i + 1 print(ans)