#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
long long a[N], ans;
int main() {
  long long i, t = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
  }
  sort(a, a + n + 1);
  for (i = 0; i <= n; ++i)
    if (!i || a[i] != a[i - 1]) {
      ans += (t - 1) * t / 2;
      t = 1;
    } else {
      ++t;
    }
  if (t) ans += (t - 1) * t / 2;
  printf("%lld\n", ans);
  return 0;
}
