#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans = 0;
  cin >> n;
  vector<long long> a(n + 1);
  for (long long i = 0; i < n; i++) {
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  for (int i = 1; i < n; i++) {
    for (long long j = 0; j < n - i + 1; j++) {
      long long l = j, r = j + i;
      if (a[r] - a[l] == 0) ans++;
    }
  }
  cout << ans << endl;
}
