#include <bits/stdc++.h>
int a[300004], pos[300004];
using namespace std;
int main() {
  int n, temp, c;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= min(n, i + 5); j++) {
      temp = 2 * a[j] - a[i];
      if (temp <= n && temp > 0 && pos[temp] > j) {
        c = 1;
        break;
      } else
        c = 0;
      temp = 2 * a[i] - a[j];
      if (temp <= n && temp > 0 && pos[temp] < i) {
        c = 1;
        break;
      } else
        c = 0;
    }
    if (c == 1) break;
  }
  if (c)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
