#include <bits/stdc++.h>
using namespace std;
const long MAX_N = 2 * pow(10, 5);
int main() {
  int N;
  long A[MAX_N];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    long sum = 0;
    int r = 0;
    for (int j = i; j < N; j++) {
      sum += A[j];
      if (!sum) r++;
    }
    A[i] = r;
  }
  long sum = 0;
  for (int i = 0; i < N; i++) sum += A[i];
  cout << sum << endl;
}
