#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(int argc, char **argv) {
  int n;
  cin >> n;
  vector<ll> a(n + 3);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<ll> c_(n, 0);
  for (int i = 0; i < n; ++i) {
    ll sum = a[i];
    for (int j = i + 1; j < n; ++j) {
      if (sum == 0) {
        ++c_[i];
      }
      sum += a[j];
    }
  }
  vector<ll> cum_sum(n, 0);
  for (int i = 0; i < n - 1; ++i) cum_sum[i + 1] = cum_sum[i] + c_[i];
  std::cout << cum_sum[n - 1] << std::endl;
}
