#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const long long INFF = 1e18;
const double EPS = 1e-9;
const double PI = acos(-1.0);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
void Yes(bool f) {
  if (f) {
    cout << ("Yes") << endl;
    ;
  } else {
    cout << ("No") << endl;
  }
}
void yES(bool f) {
  if (f) {
    cout << ("yES") << endl;
    ;
  } else {
    cout << ("nO") << endl;
  }
}
void Yay(bool f) {
  if (f) {
    cout << ("Yay!") << endl;
    ;
  } else {
    cout << (":(") << endl;
  }
}
long long N;
long long A[22], A_S[22];
void init() {
  cin >> (N);
  ;
  for (int(i) = (0); (i) < ((N)); ++(i)) scanf("%lld", A + i);
  for (int(i) = (0); (i) < ((N)); ++(i)) A_S[i + 1] = A_S[i] + A[i];
}
signed main() {
  init();
  map<long long, long long> mp;
  for (int(i) = (0); (i) < ((N + 1)); ++(i)) {
    long long v = A_S[i];
    if (mp.count(v) == 0) {
      mp[v] = 1;
    } else {
      ++mp[v];
    }
  }
  long long ans = 0;
  for (auto i = mp.begin(); i != mp.end(); ++i) {
    long long q = i->second;
    if (q > 1) {
      ans += q * (q - 1) / 2;
    }
  }
  cout << (ans) << endl;
  ;
}
