#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &a) {
  register int b = 1, c;
  a = 0;
  for (c = fgetc(stdin); c > 57 || c < 48; c = fgetc(stdin))
    if (c == 45) b = -1;
  for (; c >= 48 && c <= 57; c = fgetc(stdin)) a = a * 10 + c - 48;
  a *= b;
}
int n, a[200000 + 5];
map<long long, int> M;
int main() {
  read(n);
  for (int i = 0; i < n; i++) read(a[i]);
  int sum = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    ans += M[sum] + !sum;
    M[sum]++;
  }
  printf("%lld\n", ans);
  return 0;
}
