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