#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long a[1000001];
  long long sa[1000001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long c = 0;
  long long sub_c = 0;
  sa[0] = 0;
  for (int i = 0; i < n; i++) {
    sa[i + 1] = a[i] + sa[i];
    sub_c++;
    if (sa[i + 1] == 0) {
      c = c + sub_c;
    }
  }
  cout << c << endl;
}
