#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = (0); i < (N); ++i) scanf("%d", &A[i]);
  vector<long long> s(N + 1, 0);
  partial_sum((A).begin(), (A).end(), s.begin() + 1);
  unordered_map<long long, long long> nums;
  for (int i = (0); i < (N + 1); ++i) nums[s[i]]++;
  ll cnt = 0, num;
  for (pair<long long, long long> p : nums) {
    num = p.second;
    cnt += num * (num - 1) / 2;
  }
  cout << cnt << "\n";
  return 0;
}
