#include <bits/stdc++.h>
using namespace std;
int getint() {
  int n;
  scanf("%d", &n);
  return n;
}
vector<int> getints(int n) {
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  return a;
}
int main(void) {
  int N = getint();
  vector<int> A = getints(N);
  for (int i = 1; i < N; i++) A[i] = A[i - 1] + A[i];
  sort(A.begin(), A.end());
  int t = 0;
  int c = 1;
  int s = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == t) {
      c++;
    } else {
      if (c > 1) {
        s += c * (c - 1) / 2;
      }
      c = 1;
      t = A[i];
    }
  }
  if (c > 1) s += c * (c - 1) / 2;
  cout << s << endl;
  return 0;
}
