#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
signed main() {
  long long a;
  cin >> a;
  vector<long long> b(a);
  for (long long i = 0; i < a; i++) cin >> b[i];
  vector<long long> c(a + 1);
  c[0] = 0;
  for (long long i = 1; i <= a; i++) c[i] = b[i - 1] + c[i - 1];
  sort(c.begin(), c.end());
  long long d = 0, e = 0;
  for (long long i = 0; i < a + 1; i++) {
    d++;
    if (c[i] != c[i + 1]) {
      e += d * (d - 1) / 2;
      d = 0;
      if (i == a) e += d * (d - 1) / 2;
    }
  }
  cout << e << endl;
}
