#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T = int>
inline T nxt() {
  char c = nc();
  T x = 0;
  int f = 1;
  for (; c > '9' || c < '0'; c = nc())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = nc())
    ;
  x *= f;
  return x;
}
const int N = 100123;
int a[N];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n = nxt();
  long long s = 0;
  long long ans = 0;
  map<int, int> m;
  m[0] = 1;
  for (int i = 0; i < (n); ++i) s += nxt(), ans += m[s], m[s]++;
  cout << ans << '\n';
}
