#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 3e5 + 10, maxm = 4e5 + 10, lg = 26, mod = 1e9 + 7,
                inf = 1e18;
long long pwm(long long a, long long b) {
  long long ret = 1;
  for (; b; (a *= a) %= mod, b >>= 1)
    if (b & 1) (ret *= a) %= mod;
  return ret;
}
long long bit[maxn][2];
void add(long long i, long long x, bool b) {
  for (; i < maxn; i += (i & -i)) (bit[i][b] += x) %= mod;
}
long long rget(long long i, bool b) {
  long long ret = 0;
  for (; i; i -= (i & -i)) (ret += bit[i][b]) %= mod;
  return ret;
}
long long get(long long l, long long r, bool b) {
  return (rget(r, b) - rget(l - 1, b) + mod) % mod;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1, x; i <= n; i++) {
    cin >> x;
    long long p1 = pwm(2, x), p2 = pwm(2, n - x + 1);
    add(x, p1, 0), add(x, p2, 1);
    long long len = min(x - 1, n - x);
    if (get(x, x + len, 0) * p2 % mod != get(x - len, x, 1) * p1 % mod)
      return cout << "YES\n", 0;
  }
  cout << "NO\n";
  return 0;
}
