#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge {
  ll from;
  ll to;
  ll cost;
};
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> sum(n + 1);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) sum[i + 1] = sum[i] + a[i];
  map<int, ll> mp;
  for (int i = 0; i < n + 1; ++i) mp[sum[i]]++;
  ll ans = 0;
  for (auto &x : mp) ans += x.second * (x.second - 1) / 2;
  cout << ans << endl;
  return 0;
}
