#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  ll n, a[200001], result = 0;
  map<int, int> count;
  cin >> n;
  FOR(i, 0, n) cin >> a[i];
  FOR(i, 1, n) {
    a[i] += a[i - a];
    count[a[i]]++;
  }
  count[a[0]]++;

  for(it = mp.begin(); it != mp.end(); it++) {
    if (it->second - 1) {
      FOR(i, 0, it->second) result += i + 1;
    }
  }

  result += count[0];
  cout << result << endl;
}