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