#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  map<int, int> mp;
  long long int sum = 0;
  mp[sum]++;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    sum += tmp;
    mp[sum]++;
  }
  int counter = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second < 2) {
      continue;
    } else {
      counter += itr->second * (itr->second - 1) / 2;
    }
  }
  std::cout << counter << std::endl;
}
