#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> A(n);
  long long sum = 0, ans = 0;
  map<long long, long long> count;
  count[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    sum += A[i];
    cout << "sum = " << sum << endl;
    ans += count[sum];
    cout << "ans =" << ans << endl;
    count[sum]++;
    cout << "count[" << sum << "] = " << count[sum] << endl;
  }
  cout << ans;
  return 0;
}
