#include <bits/stdc++.h>
using namespace std;
long long T, n, a[300010], c[300010], l[300010], r[300010];
long long lowbit(long long x) { return x & (-x); }
void add(long long x, long long k) {
  for (long long i = x; i <= n; i += lowbit(i)) c[i] += k;
}
long long query(long long x) {
  long long sum = 0;
  for (long long i = x; i >= 1; i -= lowbit(i)) sum += c[i];
  return sum;
}
signed main() {
  memset(l, 0, sizeof(l));
  memset(r, 0, sizeof(r));
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  memset(c, 0, sizeof(c));
  for (long long i = 1; i <= n; i++) {
    if (2 * a[i] - 1 <= n)
      l[i] = query(2 * a[i] - 1);
    else
      l[i] = query(n) - query(2 * a[i] - n - 1);
    add(a[i], a[i]);
  }
  memset(c, 0, sizeof(c));
  for (long long i = n; i >= 1; i--) {
    if (2 * a[i] - 1 <= n)
      r[i] = query(2 * a[i] - 1);
    else
      r[i] = query(n) - query(2 * a[i] - n - 1);
    add(a[i], a[i]);
  }
  long long f = 0;
  for (long long i = 1; i <= n; i++)
    if (l[i] % (2 * a[i]) && r[i] % (2 * a[i])) {
      printf("YES\n");
      f = 1;
      break;
    }
  if (!f) printf("NO\n");
  return 0;
}
