#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<map<long long, long long>> counts(N);
  counts[0][A[0]]++;
  for (int i = 1; i < N; i++) {
    for (auto s : counts[i - 1]) {
      counts[i][s.first + A[i]] += s.second;
    }
    counts[i][A[i]]++;
  }
  long long total = 0;
  for (auto c : counts) total += c[0];
  cout << total << endl;
  return 0;
}
