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