#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans, cnt;
  int a[200000];
  vector<int> arr(0);
  vector<int> num(0);
  ans = 0;
  cnt = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    arr.push_back(a[i]);
    num.push_back(cnt);
    cnt = 1;
    int j = 0;
    while (j < arr.size() - 1) {
      arr[j] += a[i];
      if (arr[j] == 0) {
        ans += num[j];
        cnt += num[j];
        arr.erase(arr.begin() + j);
        num.erase(num.begin() + j);
      } else {
        j++;
      }
    }
    if (arr[arr.size() - 1] == 0) {
      ans += num[arr.size()];
      arr.erase(arr.begin() + arr.size());
      num.erase(num.begin() + arr.size());
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}
