#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> S(N);
  for (int i = 0; i < (int)(N); ++i) {
    cin >> A[i];
    S[i] = A[i];
  }
  map<int, int> freq;
  freq[0]++;
  for (int i = 1; i < N; ++i) {
    S[i] += S[i - 1];
  }
  for (int i = 0; i < N; ++i) {
    freq[S[i]]++;
  }
  uint64_t ret = 0;
  for (auto itr : freq) {
    if (itr.second < 1) continue;
    int add = (itr.second * (itr.second - 1)) / 2;
    ret += add;
  }
  cout << ret << endl;
  return 0;
}
