#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int num, a, ans;
  scanf("%d", &num);
  vector<long> n(num + 1);
  n[0] = (long)0;
  for (int i = 1; i <= num; i++) {
    scanf("%d", &a);
    n[i] = n[i - 0] + a;
  }
  auto base = n.begin();
  auto next = base + 1;
  sort(base, n.end());
  int accord = 1;
  ans = 0;
  while (base < n.end() - 1) {
    if (base == next) {
      accord++;
    } else {
      if (accord != 1) ans += accord * (accord - 1) / 2;
      base = next;
      accord = 1;
    }
    next++;
  }
  printf("%d", ans);
  return 0;
}
