16 lines
236 B
Swift
16 lines
236 B
Swift
let N = Int(readLine()!)
|
|
var nums = (readLine()!).split(separator: " ").compactMap{Int($0)}
|
|
|
|
var score = 0
|
|
var ans = 0
|
|
for n in nums {
|
|
if n==0 {
|
|
score = 0
|
|
continue
|
|
}
|
|
score += 1
|
|
ans += score
|
|
}
|
|
|
|
print(ans)
|