#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 233;
int n;
long long a[maxn], sum[maxn];
template <class T>
inline void read(register T& x) {
  x = 0;
  register int f = 0;
  register char ch = getchar();
  while (!isdigit(ch)) {
    f |= (ch == '-');
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  stable_sort(sum, sum + n + 1);
  long long ans = 0;
  for (int i = 0; i <= n;) {
    int now = sum[i];
    int cnt = 0;
    while (sum[i] == now && i <= n) {
      cnt++;
      i++;
    }
    ans += 1LL * cnt * (cnt - 1) / 2;
  }
  printf("%lld", ans);
  return 0;
}
