#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ll> dp(n + 1, 0);
  for (int i = 0; i < (n); ++i) {
    ll t;
    cin >> t;
    dp[i + 1] = dp[i] + t;
  }
  ll cnt = 0;
  for (int i = (n - 1); i >= 0; --i) {
    sort(dp.begin() + i + 1, dp.end());
    auto it = lower_bound(dp.begin() + i + 1, dp.end(), dp[i]);
    int t = 0;
    while (it != dp.end() && *it == dp[i]) {
      it++;
      t++;
    }
    cnt += t;
  }
  cout << cnt << endl;
  return 0;
}
