#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
long long sum[200005];
map<long long, int> mp;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sum[0] = a[0];
  for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];
  for (int i = 0; i < n; i++) {
    if (mp.find(sum[i]) != mp.end())
      mp[sum[i]]++;
    else
      mp[sum[i]] = 1;
  }
  long long ans = 0;
  for (map<long long, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    if (it->first == 0) ans += it->second;
    ans += it->second * (it->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
