#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
long long sum, x, s[maxn], ans;
int n, j, y;
int a[maxn];
int main() {
  while (scanf("%d", &n) != EOF) {
    map<long long, int> q;
    sum = 0;
    j = 0;
    ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
      s[++j] = sum;
      q[sum]++;
    }
    for (int i = 1; i <= j; i++) {
      x = s[i];
      y = q[x];
      if (x == 0) ans++;
      ans += y * (y - 1) / 2;
      q[x] = 1;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
