#include <bits/stdc++.h>
using namespace std;
long long dict[200005];
long long prefix[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> dict[i];
  }
  prefix[0] = 0;
  for (int i = 0; i < N; ++i) {
    prefix[i + 1] = prefix[i] + dict[i];
  }
  map<long long, int> check;
  for (int i = 0; i <= N; ++i) {
    auto it = check.find(prefix[i]);
    if (it != check.end()) {
      int count = it->second;
      check.erase(it);
      check.insert(make_pair(prefix[i], count + 1));
    } else {
      check.insert(make_pair(prefix[i], 1));
    }
  }
  long long answer = 0;
  for (auto x : check) {
    int count = x.second;
    answer += count * (count - 1) / 2;
  }
  cout << answer << "\n";
  return 0;
}
