#include <bits/stdc++.h>
using namespace std;
int a[300001], p[300001];
int window = 150;
void win() {
  cout << "YES" << endl;
  exit(0);
}
int main() {
  int n;
  cin >> n;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> a[i];
    p[a[i]] = i;
  }
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < min(n, i + window); ++j) {
      int right = 2 * a[j] - a[i];
      int left = 2 * a[i] - a[j];
      if (left > 0 && left < n && p[left] < i) win();
      if (right > 0 && right < n && p[right] > j) win();
    }
  cout << "NO\n";
  return 0;
}
