#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
void solve() {}
long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}
int main() {
  ll n;
  ll ans = 0;
  cin >> n;
  vector<ll> sum(n), a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sum[0] = a[0];
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 0; i < n; i++) {
    if (sum[i] == 0) {
      ans++;
    }
  }
  sort((sum).begin(), (sum).end());
  sum.push_back(0);
  ll pre = sum[0];
  int cnt = 1;
  for (int i = 1; i <= n; i++) {
    if (pre == sum[i]) {
      cnt++;
    } else if (pre != sum[i]) {
      pre = sum[i];
      if (cnt != 1) {
        ans += combi(cnt, 2);
      }
      cnt = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
