#include <bits/stdc++.h>
using namespace std;
int inf = 1000000000;
template <typename T>
T GCD(T a, T b) {
  while (max(a, b) % min(a, b)) {
    if (a > b)
      a = a % b;
    else
      b = b % a;
  }
  return min(a, b);
}
template <typename T>
T LCM(T a, T b) {
  return a / GCD(a, b) * b;
}
int a[200010], r[200010];
map<int, int> mp;
int main() {
  int n;
  long long ans = 0;
  cin >> n >> a[0];
  r[0] = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    r[i] += r[i - 1];
    r[i] += a[i];
  }
  mp[0] = 1;
  for (int i = 0; i < n; i++) {
    ans += mp[r[i]];
    mp[r[i]]++;
  }
  ans += mp[0] - 1;
  cout << ans << endl;
  return 0;
}
