func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     while (b > 0) {       a %= b;       swap(a, b);     }     return a;   }   template <class _T>   inline _T sqr(const _T& first) {     return first * first;   }   template <class _T>   inline string tostr(const _T& a) {     ostringstream os(  );     os << a;     return os.str();   }   const long double PI = 3.1415926535897932384626433832795L;   const double EPS = 1e-9;   char TEMPORARY_CHAR;   const int INF = 1e9;   inline void input(int& a) {     a = 0;     while (((TEMPORARY_CHAR = getchar()) >  9  || TEMPORARY_CHAR <  0 ) &&            (TEMPORARY_CHAR !=  - )) {     }     char neg = 0;     if (TEMPORARY_CHAR ==  - ) {       neg = 1;       TEMPORARY_CHAR = getchar();     }     while (TEMPORARY_CHAR <=  9  && TEMPORARY_CHAR >=  0 ) {       a = 10 * a + TEMPORARY_CHAR -  0 ;       TEMPORARY_CHAR = getchar();     }     if (neg) a = -a;   }   inline void out(long long a) {     if (!a) putchar( 0 );     if (a < 0) {       putchar( - );       a = -a;     }     char s[20];     int i;     for (i = 0; a; ++i) {       s[i] =  0  + a % 10;       a /= 10;     }     for (int j = (i)-1; j >= 0; j--) putchar(s[j]);   }   inline int nxt() {     int(ret);     input((ret));     ;     return ret;   }   const int MAXN = 300000;   long long powers[MAXN + 1];   struct data {     int len;     long long data1;     long long data2;   };   data merge(const data& l, const data& r) {     data res;     res.len = l.len + r.len;     res.data1 = r.data1 + l.data1 * powers[r.len];     res.data2 = l.data2 + r.data2 * powers[l.len];     return res;   }   int main() {     int(n);     input((n));     ;     int first[n];     powers[0] = 1;     for (int i = 1; i <= n; ++i) {       powers[i] = powers[i - 1] * 3;     }     for (int i = 0; i < n; ++i) {       first[i] = nxt() - 1;     }     data t[n + n];     for (int i = 0; i < n; ++i) {       t[i + n].len = 1;       t[i + n].data1 = t[i + n].data2 = 0;     }     for (int i = n - 1; i > 0; --i) {       t[i] = merge(t[i + i], t[i + i + 1]);     }     for (int i = 0; i < n; ++i) {       t[first[i] + n].data1 = t[first[i] + n].data2 = 1;       int pos = first[i] + n;       for (pos >>= 1; pos; pos >>= 1) {         t[pos] = merge(t[pos + pos], t[pos + pos + 1]);       }       int r = min(first[i], n - first[i] - 1);       data L{0, 0, 0};       data R{0, 0, 0};       int a = first[i] - r, b = first[i] + r;       for (a += n, b += n; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1) {         if (a & 1) {           L = merge(L, t[a]);         }         if (!(b & 1)) {           R = merge(t[b], R);         }       }       data res = merge(L, R);       if (res.data1 != res.data2) {         puts( YES );         return 0;       }     }     puts( NO );     return 0;   }   