#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000, N = 300000;
int pw[N + 5];
class node {
 public:
  int h1, h2, sz;
  bool is_pal() { return h1 == h2; }
};
node merge(node le, node ri) {
  node ans;
  ans.sz = le.sz + ri.sz;
  ans.h1 = le.h1 * pw[ri.sz] + ri.h1;
  ans.h2 = ri.h2 * pw[le.sz] + le.h2;
  return ans;
}
node ST[4 * N + 5];
node init(int i, int b, int s) {
  if (b == s) return ST[i] = (node){0, 0, 1};
  int o = (b + s) / 2;
  return ST[i] = merge(init(2 * i, b, o), init(2 * i + 1, o + 1, s));
}
node update(int i, int b, int s, int x) {
  if (x < b || x > s) return ST[i];
  if (b == s) return ST[i] = (node){1, 1, 1};
  int o = (b + s) / 2;
  return ST[i] = merge(update(2 * i, b, o, x), update(2 * i + 1, o + 1, s, x));
}
node query(int i, int b, int s, int x, int y) {
  if (x > s || y < b) return (node){0, 0, 0};
  if (x <= b && y >= s) return ST[i];
  int o = (b + s) / 2;
  return merge(query(2 * i, b, o, x, y), query(2 * i + 1, o + 1, s, x, y));
}
int n;
int main() {
  int x;
  scanf("%d", &n);
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * 11;
  init(1, 1, n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    int len = min(x, n - x + 1);
    node q = query(1, 1, n, x - len + 1, x + len - 1);
    if (!q.is_pal()) {
      puts("YES");
      return 0;
    }
    update(1, 1, n, x);
  }
  puts("NO");
  return 0;
}
