#include <bits/stdc++.h>
using namespace std;
namespace FastIO {
template <typename tp>
inline void read(tp &x) {
  x = 0;
  register char c = getchar();
  register bool f = 0;
  for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar())
    ;
  if (f) x = -x;
}
template <typename tp>
inline void write(tp x) {
  if (x == 0) return (void)(putchar('0'));
  if (x < 0) putchar('-'), x = -x;
  int pr[20];
  register int cnt = 0;
  for (; x; x /= 10) pr[++cnt] = x % 10;
  while (cnt) putchar(pr[cnt--] + '0');
}
template <typename tp>
inline void writeln(tp x) {
  write(x);
  putchar('\n');
}
}  // namespace FastIO
using namespace FastIO;
const int N = 2e5 + 1;
int n, i;
long long d[N];
map<int, int> q;
int main() {
  read(n);
  int ans = 0;
  q[0]++;
  int cache;
  for ((i) = (1); (i) <= (n); ++(i)) read(d[i]), q[d[i] += d[i - 1]]++;
  for (auto i = q.begin(); i != q.end(); i++)
    if ((*i).second == 1)
      continue;
    else {
      cache = (*i).second;
      ans += (cache * cache - cache) >> 1;
    }
  writeln(ans);
}
