#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, 0);
  sum[0] = a[0];
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  map<int, int> mp;
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    cnt += mp[sum[i]];
    mp[sum[i]]++;
  }
  cnt += mp[0];
  cout << cnt << endl;
}
