#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> sum = vector<int>(n, 0);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> sum[i];
    if (i != 0) {
      sum[i] += sum[i - 1];
    }
    if (sum[i] == 0) ans++;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      sum[j] -= sum[i];
      if (sum[j] == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
