#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> a(n), sum(n + 1, 0);
  map<long long, long long> nums;
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < n + 1; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  for (int i = 0; i < n + 1; i++) nums[sum[i]]++;
  long long count = 0;
  for (auto it : nums) {
    long long num = it.second;
    count += (num - 1) * num / 2;
  }
  cout << count << endl;
}
