#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
int n;
int a[MAXN];
long long asum[MAXN + 1];
long long b[MAXN + 1];
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  asum[0] = 0;
  for (int i = (0); i < (n); ++i) asum[i + 1] = asum[i] + a[i];
  for (int i = (0); i <= (n); ++i) b[i] = asum[i];
  sort(b, b + n + 1);
  long long ret = 0;
  for (int l = 0, r = l; l <= n; l = r) {
    while (r <= n && b[l] == b[r]) ++r;
    int cnt = r - l;
    ret += cnt * (cnt - 1) / 2;
  }
  printf("%lld\n", ret);
}
int main() {
  run();
  return 0;
}
