func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   const double eps = 1e-9;   const int N = 1 << 19;   const int P = (int)1e9 + 7;   const int Z = 239;   inline int add(int a, int b) {     a += b;     if (a >= P) a -= P;     return a;   }   int powP[2 * N];   inline int shift(int a, int n) { return (a * (long long)powP[n]) % P; }   int hash1[2 * N];   int hash2[2 * N];   int len[2 * N];   inline void upd(int x, int dx) {     x += N;     hash1[x] = dx;     hash2[x] = dx;     while (x > 1) {       x >>= 1;       hash1[x] = add(hash1[2 * x], shift(hash1[2 * x + 1], len[2 * x]));       hash2[x] = add(hash2[2 * x + 1], shift(hash2[2 * x], len[2 * x]));     }   }   int vleft[2 * N], vleftc = 0;   int vright[2 * N], vrightc = 0;   inline int get1(int l, int r) {     if (l > r) return 0;     l += N;     r += N;     vleftc = 0;     vrightc = 0;     while (l <= r) {       if ((l & 1) == 1) vleft[vleftc++] = l;       if ((r & 1) == 0) vright[vrightc++] = r;       l = (l + 1) >> 1;       r = (r - 1) >> 1;     }     int res = 0;     int toshift = 0;     for (int i = 0; i < vleftc; ++i) {       int v = vleft[i];       res = add(res, shift(hash1[v], toshift));       toshift += len[v];     }     for (int i = vrightc - 1; i >= 0; --i) {       int v = vright[i];       res = add(res, shift(hash1[v], toshift));       toshift += len[v];     }     return res;   }   inline int get2(int l, int r) {     if (l > r) return 0;     l += N;     r += N;     vleftc = 0;     vrightc = 0;     while (l <= r) {       if ((l & 1) == 1) vleft[vleftc++] = l;       if ((r & 1) == 0) vright[vrightc++] = r;       l = (l + 1) >> 1;       r = (r - 1) >> 1;     }     int res = 0;     int toshift = 0;     for (int i = 0; i < vrightc; ++i) {       int v = vright[i];       res = add(res, shift(hash2[v], toshift));       toshift += len[v];     }     for (int i = vleftc - 1; i >= 0; --i) {       int v = vleft[i];       res = add(res, shift(hash2[v], toshift));       toshift += len[v];     }     return res;   }   int a[N];   int main() {     powP[0] = 1;     for (int i = 1; i <= N; ++i) powP[i] = (powP[i - 1] * (long long)Z) % P;     for (int i = 2 * N - 1; i >= 1; --i) {       if (i >= N)         len[i] = 1;       else         len[i] = 2 * len[2 * i];     }     int n;     scanf( %d , &n);     for (int i = 0; (i) < (n); ++i) scanf( %d , &a[i]);     for (int i = 0; (i) < (n); ++i) a[i] -= 1;     bool res = false;     for (int i = 0; (i) < (n); ++i) {       int val = a[i];       if (val <= n - val - 1) {         int left = get1(0, val - 1);         int right = get2(val + 1, 2 * val);         if (left != right) {           res = true;         }       } else {         int left = get1(val - (n - 1 - val), val - 1);         int right = get2(val + 1, n - 1);         if (left != right) {           res = true;         }       }       upd(val, 1);     }     if (res)       printf( YES n );     else       printf( NO n );     return 0;   }   