#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];
  for (int i = 1; i <= (N - 1); i++) A[i] += A[i - 1];
  map<long long, int> mp;
  for (int i = 0; i < (N); i++) mp[A[i]]++;
  mp[0]++;
  long long ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ans += (itr->second) * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
