#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int count = 0;
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long int i = 0; i < n - 1; i++) {
    a[i + 1] += a[i];
  }
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 0) {
      continue;
    }
    bool flag = false;
    long long int tmp = 0;
    for (long long int j = i + 1; j < n; j++) {
      if (a[j] == 0) {
        tmp++;
      }
      if (a[i] == a[j]) {
        count++;
        flag = true;
      }
    }
    if (flag) {
      count += tmp;
    }
  }
  cout << count << endl;
  return 0;
}
