#include <bits/stdc++.h>
using namespace std;
int n, a[100005], ans;
int getnum(int x) {
  x--;
  int mem = 0;
  mem = x * x + x;
  return mem / 2;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] += a[i - 1];
  }
  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 = 1;
    } else
      length++;
  }
  if (a[n] == a[n - 1]) ans += getnum(length);
  printf("%d\n", ans);
  return 0;
}
