#include <bits/stdc++.h>
using namespace std;
long long a[220000];
long long sum[220000];
map<long long, int> t;
int main() {
  int n;
  long long ans = 0;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> a[0];
  sum[0] = a[0];
  t[sum[0]] = 1;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
    if (sum[i] == 0) ans++;
    if (t.find(sum[i]) != t.end()) {
      ans += t[sum[i]];
      t[sum[i]]++;
    } else
      t[sum[i]] = 1;
  }
  cout << ans << endl;
  return 0;
}
