#include <bits/stdc++.h>
using namespace std;
long long combination(int n, int r) {
  r = min(r, n - r);
  vector<vector<long long>> x(n + 1, vector<long long>(r + 1));
  x.at(0).at(0) = 1;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < r + 1; j++) {
      if (j == 0) {
        x.at(i).at(j) = 1;
      } else {
        x.at(i).at(j) = x.at(i - 1).at(j - 1) + x.at(i - 1).at(j);
      }
    }
  }
  return x.at(n).at(r);
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> s(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + a[i - 1];
  }
  sort((s).begin(), (s).end());
  int count = 0;
  int memo = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[i + 1]) {
      memo++;
      if (i == n - 1) {
        count += combination(memo, 2);
      }
    } else {
      if (memo == 1) {
        continue;
      }
      count += combination(memo, 2);
      memo = 1;
    }
  }
  cout << count << endl;
}
