https://www.acmicpc.net/problem/2506
n=int(input()) sum=0 count=0 k=list(map(int,input().split())) for i in range(n): a=k[i] if a==1: count+=1 sum+=count else: count=0 print(sum)