#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;
  vector<long long> A(N + 1, 0LL);
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  vector<long long> csum(N + 1, 0LL);
  for (int i = 1; i <= N; ++i) {
    csum[i] = csum[i - 1] + A[i];
  }
  map<int, int> cnt;
  cnt.clear();
  for (int i = 0; i <= N; ++i) {
    ++cnt[csum[i]];
  }
  long long res = 0LL;
  map<int, int>::iterator it = cnt.begin();
  for (; it != cnt.end(); ++it) {
    int curr = (*it).second;
    res += (long long)curr * ((long long)curr - 1LL) / 2LL;
  }
  cout << res << endl;
  return 0;
}
