#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200010];
  long long ans = 0;
  vector<long long> tmp;
  vector<int> plus;
  int memo[200010] = {};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int size;
  for (int i = 0; i < n; i++) {
    size = tmp.size();
    for (int j = 0; j <= size; j++) {
      if (j == size) {
        if (memo[i] == 0) {
          tmp.push_back(a[i]);
          plus.push_back(1);
        }
      } else {
        tmp[j] += a[i];
        if (tmp[j] == 0) {
          ans += plus[j];
          plus[j]++;
          memo[i + 1] = 1;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
