#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n + 1, 0);
  map<long long, long long> nums;
  for (int i = 0; i < n; i++) {
    b[i + 1] = b[i] + a[i];
  }
  for (int i = 0; i < n + 1; i++) nums[b[i]]++;
  long long res = 0;
  for (auto it : nums) {
    long long num = it.second;
    res += num * (num - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
