#include <bits/stdc++.h>
using namespace std;
int n;
int a[300005], b[300005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= min(n, i + 5); j++) {
      int t;
      t = 2 * a[i] - a[j];
      if (t >= 1 && t <= n && b[t] < i) {
        printf("YES");
        return 0;
      }
      t = 2 * a[j] - a[i];
      if (t >= 1 && t <= n && b[t] > j) {
        printf("YES");
        return 0;
      }
    }
  }
  printf("NO");
  return 0;
}
