#include <bits/stdc++.h>
using namespace std;
long long findSubArrays(int arr[], int n) {
  long long ans = 0;
  unordered_map<int, vector<int>> map;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) ans++;
    if (map.find(sum) != map.end()) {
      vector<int> vc = map[sum];
      for (auto it = vc.begin(); it != vc.end(); it++) ans++;
    }
    map[sum].push_back(i);
  }
  return ans;
}
void print(vector<pair<int, int>> out) {
  for (auto it = out.begin(); it != out.end(); it++)
    cout << "Subarray found from Index " << it->first << " to " << it->second
         << endl;
}
int a[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    scanf("%d", &a[i]);
  }
  long long ans = findSubArrays(a, n);
  cout << ans << endl;
  return 0;
}
