#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  vector<bool> C;
  A.resize(N);
  C.resize(N, true);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int all_count = 0;
  for (int ci = 0; ci < C.size(); ci++) {
    if (C[ci]) {
      int sum = 0;
      int count = 0;
      C[ci] = false;
      for (int i = ci; i < A.size(); i++) {
        sum += A[i];
        if (sum == 0) {
          count++;
          sum = 0;
          C[i + 1] = false;
        }
      }
      for (int j = 0; j <= count; j++) all_count += j;
    }
  }
  cout << all_count << endl;
  return 0;
}
