#include <bits/stdc++.h>
using namespace std;
int N;
int A[300000] = {0};
int tA[300000] = {0};
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  tA[0] = A[0];
  for (int i = 1; i < N; i++) {
    tA[i] = tA[i - 1] + A[i];
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      if (i == 0) {
        if (tA[j] == 0) count++;
      } else {
        if (tA[j] - tA[i - 1] == 0) count++;
      }
    }
  }
  cout << count << endl;
}
