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