func_code_string: #include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int rnd(int l, int r) { return l + rng() % (r - l + 1); }   const int N = 200010;   int n;   long long ret;   int a[N], lz[N], b[N];   int f[N][25];   int que(int i, int j) {     int t = lz[j - i + 1];     return max(f[i][t], f[j - (1 << t) + 1][t]);   }   void dnc(int l, int r) {     if (l >= r) return;     int x = que(l, r);     int p = b[x];     if (p - l < r - p)       for (int i = l, _c = p - 1; i <= _c; ++i)         ret += r >= b[x - a[i]] && b[x - a[i]] > p;     else       for (int i = p + 1, _c = r; i <= _c; ++i)         ret += l <= b[x - a[i]] && b[x - a[i]] < p;     dnc(l, p - 1);     dnc(p + 1, r);   }   int main() {     n = ({       int x = 0;       int c = getchar(), n = 0;       for (; !isdigit(c); c = getchar()) n = (c ==  - );       for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;       n ? -x : x;     });     for (int i = 1, _c = n; i <= _c; ++i)       a[i] = f[i][0] = ({         int x = 0;         int c = getchar(), n = 0;         for (; !isdigit(c); c = getchar()) n = (c ==  - );         for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;         n ? -x : x;       }),       b[a[i]] = i, lz[i] = log2(i);     for (int j = 1, _c = 20; j <= _c; ++j)       for (int i = 1, _c = n; i <= _c; ++i) {         if (i + (1 << j - 1) > n) break;         f[i][j] = max(f[i][j - 1], f[i + (1 << j - 1)][j - 1]);       }     dnc(1, n);     cout << ret;   }   