#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> m, p;
  vector<long long> dp(n);
  long long sum = 0;
  long long cou = 0;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
    sum += a[i];
    dp[i] = sum;
    if (dp[i] == 0) {
      cou++;
    }
  }
  for (int i = (0); i < (n - 2); i++) {
    for (int j = (i + 2); j < (n); j++) {
      if (dp[j] - dp[i] == 0) {
        cou++;
      }
    }
  }
  cout << cou << endl;
  return 0;
}
