#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1000000000000000000LL;
const int MOD = 1000000007;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < (n); i++) {
    cin >> a[i];
  }
  long long souwa[n + 1];
  souwa[0] = 0;
  for (long long i = 1; i <= n; ++i) {
    souwa[i] = souwa[i - 1] + a[i - 1];
  }
  long long cnt = 0;
  for (long long i = 0; i <= n - 2; ++i) {
    for (long long j = i + 2; j <= n; ++j) {
      if (souwa[j] - souwa[i] == 0) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}
