#include <bits/stdc++.h>
using namespace std;
int n;
map<long long, long long> m;
map<long long, long long>::iterator it, it2;
int main() {
  scanf("%d", &n);
  int x;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x == 0) {
      ans++;
    }
    if (m.find(0 - x) != m.end()) {
      ans += m[0 - x];
    }
    map<long long, long long> m1;
    for (it = m.begin(); it != m.end(); it++) {
      m1[it->first + x] = m[it->first];
    }
    m = m1;
    if (m.find(x) != m.end()) {
      m[x]++;
    } else {
      m[x] = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
