#include <bits/stdc++.h>
int main() {
  int n, i, j, k, sum, subSequences = 0;
  std::cin >> n;
  int a[n], p[n];
  std::vector<int> p_list;
  int p_list_len = 0;
  for (i = 0; i < n; i++) {
    std::cin >> a[i];
    p[i] = -1;
  }
  for (i = 0; i < n; i++) {
    sum = 0;
    p_list.clear();
    p_list_len = 0;
    for (j = i; j < n; j++) {
      sum += a[j];
      if (p[j] != -1 && sum == 0) {
        subSequences += p[j];
        break;
      }
      if (sum == 0) {
        subSequences += 1;
        p_list.push_back(j);
        p_list_len += 1;
        for (k = 0; k < p_list_len; k++) {
          if (p[p_list[k]] == -1)
            p[p_list[k]] = 1;
          else
            p[p_list[k]] += 1;
        }
      }
    }
  }
  std::cout << subSequences << std::endl;
  return 0;
}
