#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++) {
    cin >> A[i];
  }
  vector<int> sum(N + 1, 0);
  for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i];
  map<ll, ll> nums;
  for (int i = 0; i < N + 1; i++) nums[sum[i]]++;
  ll ans = 0;
  for (auto it : nums) {
    ll num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
