#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  T s = 0, f = 1;
  static char c;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) s = s * 10 + (c ^ 48);
  x = s * f;
}
const int MAXN = 2e5 + 7;
static int n;
static long long w[MAXN];
static map<long long, int> G;
static long long ans;
inline void init() {
  read(n);
  G[0] = 1;
  for (register int i = (1); i <= (n); ++i) {
    read(w[i]);
    w[i] += w[i - 1];
    if (!G[w[i]])
      G[w[i]] = 1;
    else
      ++G[w[i]];
    ans += G[w[i]] - 1;
  }
  printf("%lld\n", ans);
}
inline void solve() {}
inline void file() {}
int main() {
  file();
  init();
  solve();
  return 0;
}
