#include <bits/stdc++.h>
using namespace std;
const long long base = 23;
long long pre[300010], n;
struct FWT {
  long long val[300010];
  long long query(long long p) {
    long long ret = 0;
    for (long long i = p; i; i -= (i & (-i))) {
      ret += val[i] * pre[p - i];
    }
    return ret;
  }
  void modify(long long p) {
    for (long long i = p; i <= n; i += (i & (-i))) {
      val[i] += pre[i - p];
    }
  }
  long long query(long long l, long long r) {
    return query(r) - query(l - 1) * pre[r - l + 1];
  }
};
FWT t[2];
signed main() {
  cin >> n;
  for (long long i = pre[0] = 1; i <= n; i++) {
    pre[i] = pre[i - 1] * base;
  }
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    long long len = min(x - 1, n - x);
    long long qwq1 = t[0].query(x - len, x - 1),
              qwq2 = t[1].query(n - x - len + 1, n - x);
    t[0].modify(x), t[1].modify(n - x + 1);
    if (qwq1 != qwq2) {
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
