#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long> a(n + 1, 0);
  long t;
  long cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> t;
    a[i + 1] = a[i] + t;
    if (a[i + 1] == 0) {
      cnt += 1;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[j] - a[i] == 0) {
        cnt += 1;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
