#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-14;
template <class T>
using vec = vector<T>;
using ll = long long;
using ull = unsigned long long;
using vi = vec<int>;
using vl = vec<ll>;
using vd = vec<double>;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using vec2 = complex<double>;
using si = set<int>;
using mii = map<int, int>;
template <class T = int>
inline T in() {
  T x;
  cin >> x;
  return x;
}
template <class T = int>
inline vec<T> in(int n) {
  vec<T> v(n);
  for (int i = (int)(0); i < (int)(n); ++i) v[i] = in<T>();
  return v;
}
template <class T = int>
inline void in(T* x, int n) {
  for (int i = (int)(0); i < (int)(n); ++i) x[i] = in<T>();
}
template <class T>
inline void print(const T& x) {
  cout << x << '\n';
}
template <class T>
inline void printd(const T& x, int d) {
  cout << fixed << setprecision(d) << x << '\n';
}
template <class T>
inline void printv(vec<T>& v) {
  int n = (v).size();
  for (int i = (int)(0); i < (int)(n); ++i) cout << v[i] << "\n "[i < n - 1];
}
template <class T>
inline void printv(vec<T>& v, int n) {
  for (int i = (int)(0); i < (int)(n); ++i) cout << v[i] << "\n "[i < n - 1];
}
template <class T>
inline void printa(T* ary, int n) {
  for (int i = (int)(0); i < (int)(n); ++i) cout << ary[i] << "\n "[i < n - 1];
}
signed main() {
  int n = in();
  vi a = in(n);
  vi sum(n);
  map<int, int> available;
  ll cnt = 0;
  sum[0] = 0;
  for (int i = (int)(1); i < (int)(n + 1); ++i) {
    sum[i] += sum[i - 1] + a[i - 1];
    if (sum[i] == 0) {
      ++cnt;
    }
    cnt += available[sum[i]];
    ++available[sum[i]];
    cerr << "cnt"
         << ": " << (cnt) << " (" << 135 << ")" << '\n';
  }
  print(cnt);
  return 0;
}
