#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<long long> A(N), cumsum(N + 1, 0);
  map<long long, int> count;
  count[0]++;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    cumsum[i + 1] = cumsum[i] + A[i];
    count[cumsum[i + 1]]++;
  }
  long long ans = 0;
  for (auto &e : count) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
