#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();
ll nCr(int n, int k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  ll result = n;
  for (int i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
void solve() {
  int N;
  cin >> N;
  int a[2 * 100000 + 5], sum[2 * 100000 + 5];
  for (int i = 0; i < int(N); ++i) cin >> a[i];
  int s = 0;
  for (int i = 0; i < int(N); ++i) {
    s += a[i];
    sum[i] = s;
  }
  map<int, int> mm;
  for (int i = 0; i < int(N); ++i) {
    mm[sum[i]]++;
  }
  ll ans = mm[0];
  for (auto t : mm) {
    int i = t.second;
    if (i >= 2) ans += nCr(i, 2);
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
