#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  map<long long, int> mp;
  vector<long long> B(n + 1);
  B[0] = 0;
  mp[0]++;
  int tmp = 0;
  for (int i = 0; i < n; i++) {
    B[i + 1] = A[i] + tmp;
    tmp = B[i + 1];
    mp[B[i + 1]]++;
  }
  long long cnt = 0;
  for (auto x : mp) {
    cnt += x.second * (x.second - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
