#include <bits/stdc++.h>
using namespace std;
using T = long long;
int main() {
  T x, n, r = 0, s = 0;
  unordered_map<T, T> a;
  scanf("%lld", &n);
  for (T i = 0; i < n; i++) scanf("%lld", &x), a[r += x]++;
  for (pair<T, T> i : a) {
    T x = i.first, y = i.second;
    if (x == 0)
      s += y * (y + 1) / 2;
    else if (y > 2)
      s += (y - 1) * (y - 2);
    else
      s += y - 1;
  }
  printf("%lld", s);
}
