#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
long long n, a[100010], ans = 0;
map<long long, int> Mp;
int main() {
  read(n);
  long long csu = 0;
  Mp[0] = 1;
  for (int i = 0; i < n; i++) {
    read(a[i]);
    csu += a[i];
    ans += Mp[csu];
    Mp[csu] += 1;
  }
  cout << ans << endl;
  return 0;
}
