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