#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N];
  queue<int> prev;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int count = 0;
  for (int i = N - 1; i >= 0; i--) {
    queue<int> cur;
    while (!prev.empty()) {
      int cur_val = prev.front() + a[i];
      prev.pop();
      if (cur_val == 0) count++;
      cur.push(cur_val);
    }
    cur.push(a[i]);
    prev = cur;
  }
  cout << count << endl;
  return 0;
}
