#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], ans;
long long minn = 1000000000000000;
long long maxn = -1000000000000000;
long long getnum(long long x) {
  long long mem = 0;
  mem = x * x + x;
  return mem / 2;
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
    maxn = max(maxn, a[i]);
    minn = min(minn, a[i]);
  }
  sort(a, a + n + 1);
  int length = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      ans += getnum(length);
      length = 0;
    } else
      length++;
  }
  printf("%lld\n", ans);
  return 0;
}
