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