#include <bits/stdc++.h>
using namespace std;
const int TOF = 85, MAX = 3e5 + 9;
int a[MAX], pos[MAX], n;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  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 + TOF); j++) {
      int nex1 = 2 * a[j] - a[i];
      if (nex1 <= n && nex1 > 0 && pos[nex1] > j) return cout << "YES", 0;
      int nex2 = 2 * a[i] - a[j];
      if (nex2 <= n && nex2 > 0 && pos[nex2] < i) return cout << "YES", 0;
    }
  cout << "NO";
}
