#include <bits/stdc++.h>
using namespace std;
inline void read(int &n) {
  int f = 1;
  char c;
  n = 0;
  (c = getchar());
  while (c < '0' || c > '9')
    c == '-' ? f = -1, (c = getchar()) : (c = getchar());
  while (c >= '0' && c <= '9')
    n = (n << 3) + (n << 1) + c - 48, (c = getchar());
  n *= f;
  return;
}
const int N = 300005;
int len[N << 2];
unsigned int lh[N << 2], rh[N << 2], seed[N];
int n, a[N];
inline void Build(int x, int l, int r) {
  if (l == r) {
    len[x] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  Build(x << 1, l, mid);
  Build(x << 1 | 1, mid + 1, r);
  len[x] = len[x << 1] + len[x << 1 | 1];
}
inline void upd(int x) {
  lh[x] = lh[x << 1] + lh[x << 1 | 1] * seed[len[x << 1]];
  rh[x] = rh[x << 1 | 1] + rh[x << 1] * seed[len[x << 1 | 1]];
}
inline void Modify(int x, int l, int r, int t) {
  if (l == r) {
    lh[x] = rh[x] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (t <= mid) Modify(x << 1, l, mid, t);
  if (t > mid) Modify(x << 1 | 1, mid + 1, r, t);
  upd(x);
}
int last = 0;
unsigned int Hash;
inline void Queryl(int x, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    Hash += lh[x] * seed[last];
    last += len[x];
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) Queryl(x << 1, l, mid, ql, qr);
  if (qr > mid) Queryl(x << 1 | 1, mid + 1, r, ql, qr);
}
inline void Queryr(int x, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    Hash += rh[x] * seed[last];
    last += len[x];
    return;
  }
  int mid = (l + r) >> 1;
  if (qr > mid) Queryr(x << 1 | 1, mid + 1, r, ql, qr);
  if (ql <= mid) Queryr(x << 1, l, mid, ql, qr);
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  Build(1, 1, n);
  seed[0] = 1;
  for (int i = 1; i <= n; i++) seed[i] = seed[i - 1] * 2333;
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    int x = a[i];
    Modify(1, 1, n, x);
    int l = min(x - 1, n - x);
    if (l) {
      unsigned int h1, h2;
      Hash = 0;
      last = 0;
      Queryl(1, 1, n, x + 1, x + l);
      h1 = Hash;
      Hash = 0;
      last = 0;
      Queryr(1, 1, n, x - l, x - 1);
      h2 = Hash;
      flag &= h1 == h2;
    }
  }
  flag ? printf("NO\n") : printf("YES\n");
  return 0;
}
