#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int w = 5, n, l, r;
  cin >> n;
  vector<int> a(n), p(n + 1);
  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; j < min(n, i + w); j++) {
      r = 2 * a[j] - a[i], l = 2 * a[i] - a[j];
      if (l > 0 && l < n && p[l] < i || r > 0 && r < n && p[r] > j) {
        cout << "YES\n";
        return 0;
      }
    }
  }
  cout << "NO\n";
  return 0;
}
