#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200001];
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int range = 2;
  int total = 0;
  int sum = n;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = 1; i <= sum; i++) {
      a[i] = a[i - 1] + a[i];
      if (a[i] <= 0) {
        flag = true;
      }
    }
    for (int i = 1; i <= sum; i++) {
      for (int j = i + 1; j <= sum; j++) {
        if (a[i] == a[j]) {
          total++;
        }
      }
    }
    range++;
  }
  cout << total << endl;
  return 0;
}
