#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  int ans = 0;
  vector<long long> sum(n);
  for (int i = 0; i < (int)(n); ++i) {
    if (i == 0)
      sum[0] = a[0];
    else
      sum[i] = sum[i - 1] + a[i];
    if (sum[i] == 0) ans++;
  }
  sort((sum).begin(), (sum).end());
  for (__typeof((sum).begin()) i = (sum).begin(), ie = (sum).end(); i != ie;
       ++i) {
    auto itr2 = upper_bound((sum).begin(), (sum).end(), *i);
    int c = itr2 - i;
    ans += c * (c - 1) / 2;
    i = itr2 - 1;
  }
  cout << ans << endl;
}
