The OX question refers to a question that has two answers correct or incorrect. In the case of consecutive answers in a test consisting of multiple OX questions, the score was calculated as follows to give additional points. If question 1 is correct, calculate it as 1 point. For the previous question, the first question that is correct while getting the answer wrong is calculated as 1 point. In addition, if the answer is correct in succession, the second question is calculated as 2, the third question is 3, ..., and the K question is calculated as K. The wrong question is calculated as 0 points.
For example, if the answer is correct in 10 OX questions as shown below, the score calculation is calculated as shown in the table below, and if it is incorrect, the total score is 1+1+2+3+1+2=10.
1 0 1 1 1 0 0 1 1 0

When the scoring results of the test questions are given, write a program to calculate the total score.
The first line is given the number of questions N (1 ≤ N ≤ 100). In the second line, 0 or 1 representing the scoring of N questions is given with a blank space between them. 0 is the case where the answer is incorrect, and 1 is the case where the answer is correct.
Prints a prime number on the first line.
20
In the first line, the total score considering additional points is output for the scoring result given in the input.
n = int(input())
a = list(map(int, input().split()))
cnt = 0
sum = 0
for i in a:
if i == 1:
cnt += 1
sum += cnt
else:
cnt = 0
print (sum)