https://www.acmicpc.net/problem/2506
#include <iostream>
using namespace std;
int main() {
int n,a;
cin>>n;
int sum=0;
int count=0;
for(int i=0;i<n;i++){
cin>>a;
if(a==1){
count++;
sum+=count;
}
else count=0;
}
cout<<sum;
}