#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  int n;
  cin >> n;
  int a[n], sum[n];
  map<long long, int> mp;
  long long cnt;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    sum[i] = a[i];
  }
  for (int i = 0; i < (n - 1); i++) sum[i + 1] += sum[i];
  for (int i = 0; i < (n); i++) mp[sum[i]]++;
  cnt = 0;
  for (auto p : mp) {
    auto k = p.first;
    auto v = p.second;
    if (k == 0) cnt += v;
    cnt += v * (v - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
