#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  int ans = 0;
  int tmp;
  int memo[n] = {};
  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;
          if(j != n-1){
            memo[j+1] = 1;
            plus++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}