#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
ull sum(int* p, int len) {
  ull s = 0;
  for (size_t i = 0; i < len; i++) {
    s += *p;
    p++;
  }
  return s;
}
int main() {
  int n;
  cin >> n;
  int* arr = new int[n];
  ull ans = 0;
  for (size_t i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (size_t i = 0; i < n; i++) {
    int j = 1;
    int s = 0;
    while (j <= n - i) {
      s += arr[i + j];
      if (s == 0) {
        ans++;
      }
      j++;
    }
  }
  cout << ans << endl;
  return 0;
}
