#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<int> CS(N + 1);
  for (int i = 0; i < N; ++i) CS[i + 1] = CS[i] + A[i];
  map<int, int> m;
  for (int i = 0; i <= N; ++i) {
    m[CS[i]]++;
  }
  long long res = 0;
  for (auto p = m.begin(); p != m.end(); p++) {
    int n = p->second;
    res += n * (n - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
