#include <bits/stdc++.h>
using namespace std;
namespace io {
const int L = (1 << 18) + 1;
char buf[L], *S, *T, c;
char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, L, stdin);
    return (S == T ? EOF : *S++);
  }
  return *S++;
}
int inp() {
  int x = 0, f = 1;
  char ch;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  return x * f;
}
unsigned long long inp_ll() {
  unsigned long long x = 0;
  int f = 1;
  char ch;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  return x * f;
}
char B[25], *outs = B + 20, *outr = B + 20;
template <class T>
inline void print(register T a, register char x = 0) {
  if (x) *--outs = x, x = 0;
  if (!a)
    *--outs = '0';
  else
    while (a) *--outs = (a % 10) + 48, a /= 10;
  if (x) *--outs = x;
  fwrite(outs, outr - outs, 1, stdout);
  outs = outr;
}
};  // namespace io
using io ::inp;
using io ::inp_ll;
using io ::print;
const int MAXN = 1 << 18;
int n;
unsigned long long a[MAXN];
unsigned long long ans;
int main() {
  n = inp();
  map<int, int> F;
  F[0] = 1;
  for (int i = 1; i <= n; ++i) {
    a[i] = a[i - 1] + inp();
    ans += F[a[i]];
    F[a[i]]++;
  }
  cout << ans << endl;
  return 0;
}
