#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
vector<pair<long long, long long>> v;
void f(long long n) {
  if (v.size() == 0) {
    v.push_back(make_pair(n, 1));
    return;
  }
  long long f = 0, l = v.size() - 1;
  if (v[f].first == n) {
    ans += v[f].second;
    v[f].second++;
    return;
  }
  if (v[l].first == n) {
    ans += v[l].second;
    v[l].second++;
    return;
  }
  while (l - f > 1) {
    long long mid = (l + f) / 2;
    if (v[mid].first == n) {
      ans += v[mid].second;
      v[mid].second++;
      return;
    }
    if (n < mid)
      l = mid;
    else
      f = mid;
  }
  v.push_back(make_pair(n, 1));
  sort(v.begin(), v.end());
  return;
}
long long n;
long long a[234567];
signed main() {
  cin >> n;
  a[0] = 0;
  f(0);
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    f(a[i]);
  }
  cout << ans << endl;
}
