#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int n, i, j, v, a[N], b[N];
void WIN() {
  puts("YES");
  exit(0);
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    b[a[i]] = i;
  }
  for (i = 1; i <= n; ++i) {
    for (j = i + 1; j <= i + 500 && j <= n; ++j) {
      v = a[i] + a[i] - a[j];
      if (v >= 1 && v <= n && b[v] < i) {
        WIN();
      }
      v = a[j] + a[j] - a[i];
      if (v >= 1 && v <= n && b[v] > j) {
        WIN();
      }
    }
  }
  puts("NO");
  return 0;
}
