#include <bits/stdc++.h>
using namespace std;
bool fun(vector<int> &v, vector<int> &pos) {
  int n = v.size();
  for (int i = 0; i < n; i++) {
    for (int a = max(0, i - 11); a < i; ++a) {
      if (v[a] < v[i] && 2 * v[i] - v[a] < n && 2 * v[i] - v[a] >= 0 &&
          pos[2 * v[i] - v[a]] > i)
        return true;
    }
    for (int a = i; a < min(n, i + 11); ++a) {
      if (v[a] < v[i] && 2 * v[i] - v[a] < n && 2 * v[i] - v[a] >= 0 &&
          pos[2 * v[i] - v[a]] < i)
        return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    --v[i];
    pos[v[i]] = i;
  }
  cout << (fun(v, pos) ? "YES" : "NO") << endl;
}
