#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<long long> A(N), B(N + 1, 0);
  B[0] = 0;
  long long i;
  for (i = 0; i < N; ++i) {
    cin >> A[i];
    B[i + 1] = A[i] + B[i];
  }
  sort(B.begin(), B.end());
  cout << "\n";
  vector<long long> neg_index(9999), pos_index(9999);
  for (i = 0; i < N + 1; i++) {
    if (B[i] >= 0) {
      pos_index[B[i]]++;
    } else {
      neg_index[abs(B[i])]++;
    }
  }
  long long ans = 0;
  for (i = 0; i < pos_index.size(); i++) {
    if (pos_index[i] > 1) {
      ans += pos_index[i] * (pos_index[i] - 1) / 2;
    }
  }
  for (i = 0; i < pos_index.size(); i++) {
    if (neg_index[i] > 1) {
      ans += neg_index[i] * (neg_index[i] - 1) / 2;
    }
  }
  cout << ans;
  return 0;
}
