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