#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> dp(n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i == 0) {
      dp[i] = a[i];
    } else {
      dp[i] = dp[i - 1] + a[i];
    }
    if (dp[i] == 0) {
      ans++;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; j++) {
      if (dp[j] - dp[i] == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
