n = input() list1 = list(map(int,input().split(' '))) workcount = [0] money = [0] for i in list1: if i==0: for j in range(len(workcount)): workcount[j]=0 elif i==1: for j in range(len(workcount)): workcount[j]+=1 money[j]+=workcount[j] ...