#include <bits/stdc++.h>
using namespace std;
unsigned int count(const int a[], const int index, const int sum) {
  if (index < 0) return 0;
  if (sum + a[index] == 0) return 1 + count(a, index - 1, 0);
  return count(a, index - 1, sum + a[index]);
}
int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += count(a, i, 0);
  }
  cout << sum;
  return 0;
}
