#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int a[1101000];
int main() {
  int n = read();
  a[0] = 1;
  int sum = 0, s = 0;
  for (int i = 1; i <= n; i++) {
    s += read();
    sum += a[s];
    a[s]++;
  }
  cout << sum;
  return 0;
}
