#include <bits/stdc++.h>
using namespace std;
int comb(int n, int r) {
  vector<vector<long long>> v(n + 1, vector<long long>(n + 1, 0));
  for (int i = 0; i < n + 1; i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int i = 1; i < n + 1; i++) {
    for (int k = 1; k < i; k++) {
      v[i][k] = (v[i - 1][k - 1] + v[i - 1][k]);
    }
  }
  return v[n][r];
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> table(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  table[0] = 0;
  for (int i = 1; i < N + 1; i++) {
    table[i] = table[i - 1] + A[i - 1];
  }
  sort(table.begin(), table.end());
  int ans = 0;
  int v = table[0];
  int count = 1;
  for (int i = 1; i < N + 1; i++) {
    if (table[i] == v) {
      count++;
    } else {
      if (count >= 2) {
        ans += comb(count, 2);
      }
      count = 1;
      v = table[i];
    }
  }
  if (count >= 2) {
    ans += comb(count, 2);
  }
  cout << ans << endl;
  return 0;
}
