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