N = int(input()) As = list(map(int, input().split())) total = 0 for i in range(N-1): for j in range(i,N-1): if (i+j+1) % 2 == As[j]: total += 1 else: break print(total)