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