https://www.acmicpc.net/problem/2506
import java.util.*;
fun main(args: Array<String>) {
val s=Scanner(System.`in`)
var n=s.nextInt()
var sum=0
var count=0
for(i in 0 until n){
var a=s.nextInt()
if(a==1){
count++
sum+=count
}
else count=0
}
print(sum)
}