#include <bits/stdc++.h>
using namespace std;
class Info {
 public:
  Info(int Ai, size_t i) {
    sum = Ai;
    first = i;
  }
  int sum;
  size_t first;
  size_t last = -1;
};
size_t GetNumberOfCombination(vector<int> A) {
  vector<Info> sumVec;
  for (size_t i = 0; i < A.size(); i++) {
    for (size_t j = 0; j < sumVec.size(); j++) {
      if (sumVec.at(j).sum == 0) continue;
      sumVec.at(j).sum += A.at(i);
      if (sumVec.at(j).sum == 0) sumVec.at(j).last = i;
    }
    sumVec.push_back(Info(A.at(i), i));
  }
  map<size_t, size_t> combination;
  set<size_t> used;
  for (auto v : sumVec) {
    if (v.sum != 0) continue;
    if (used.count(v.first)) continue;
    size_t nchain = 1;
    size_t last = v.last;
    used.insert(v.first);
    while (last + 1 < sumVec.size() && sumVec.at(last + 1).sum == 0) {
      nchain++;
      used.insert(last + 1);
      last = sumVec.at(last + 1).last;
    }
    if (combination.count(nchain) == 0) combination[nchain] = 0;
    combination[nchain]++;
  }
  size_t n = 0;
  for (auto c : combination) {
    n += c.first * (c.first + 1) / 2 * c.second;
  }
  return n;
}
int main() {
  size_t N;
  cin >> N;
  int ai;
  vector<int> A;
  for (size_t i = 0; i < N; i++) {
    cin >> ai;
    A.push_back(ai);
  }
  auto n = GetNumberOfCombination(A);
  cout << n << endl;
  return 0;
}
