#include using namespace std; int main(){ int N; cin>>N; int A[202020]; for(int i=1;i<=N;i++)cin>>A[i]; long long answer=0; long long count=0; for(int i=1;i<=N;i++){ if(A[i]==1)count++; else { answer=answer+(count*(count+1)/2); count=0; } } answer=answer+(count*(count+1)/2); cout<<(N*(N+1)/2)-answer; }