#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  long sum = 0;
  std::vector<int> v;
  std::vector<std::vector<int>> table(n);
  for (int i = 0; i < n; ++i) {
    table[i].resize(n);
  }
  v.resize(n);
  std::cin >> v[0];
  table[0][0] = v[0];
  for (int i = 1; i < n; ++i) {
    std::cin >> v[i];
    table[0][i] = table[0][i - 1] + v[i];
    if (table[0][i] == 0) ++sum;
  }
  for (int i = 1; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      table[i][j] = table[i - 1][j] - v[i - 1];
      if (table[i][j] == 0) ++sum;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}
