#include <bits/stdc++.h>
using namespace std;
int n;
int p[550000];
int a[550000];
int x;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    a[i] = x;
    p[x] = i;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < min(n, i + 4); ++j) {
      int u = 2 * a[j] - a[i];
      if (u >= 1 && u <= n && p[u] > j) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    for (int j = i + 1; j < min(n, i + 4); ++j) {
      int u = 2 * a[i] - a[j];
      if (u >= 1 && u <= n && p[u] < i) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
