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