#include <bits/stdc++.h>
using namespace std;
int N;
int data[200000];
int t;
int cnt = 0;
int result = 0;
int count_group(int arr[], int n) {
  unordered_map<int, vector<int>> map;
  vector<pair<int, int>> out;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) cnt++;
    if (map.find(sum) != map.end()) {
      vector<int> vc = map[sum];
      for (auto it = vc.begin(); it != vc.end(); it++) cnt++;
    }
    map[sum].push_back(i);
  }
  return cnt;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> data[i];
  }
  cout << count_group(data, N);
}
