fork download
  1. n=int(input())
  2. tab=input()
  3. s=0
  4. wschod=0
  5. for i in range(n):
  6. if tab[i*2]=='0':
  7. wschod+=1
  8. else:
  9. s+=wschod
  10. print(s)
Success #stdin #stdout 0.03s 9868KB
stdin
5
1 0 0 1 1
stdout
4