func_code_string: #include <bits/stdc++.h>   using namespace std;   using INT = long long;   int n;   int a[200010];   vector<int> B[200010];   void add(int u, int val) {     for (; u <= n; u += u & -u) B[u].push_back(val);   }   int calc(int u, int val) {     int ans = 0;     for (; u; u -= u & -u) {       int id = lower_bound(B[u].begin(), B[u].end(), val) - B[u].begin();       ans += B[u].size() - id;     }     return ans;   }   int calc(int l, int r, int val) {     if (l > r) return 0;     return calc(r, val) - calc(l - 1, val);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) add(i, min(a[i], n));     for (int i = 1; i <= n; i++) sort(B[i].begin(), B[i].end());     INT ans = 0;     for (int i = 1; i < n; i++) {       ans += calc(i + 1, min(n, a[i]), i);     }     cout << ans << endl;     return 0;   }   