#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T& a, T const& b) {
  if (b < a) a = b;
}
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
using ll = long long;
const ll mod = LLONG_MAX;
int a[112345];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  map<ll, int> cnt;
  ll sum = 0;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum == 0) ans++;
    ans += cnt[sum];
    cnt[sum]++;
  }
  cout << ans << endl;
}
