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