#include int main() { int n, m; scanf("%d %d", &n, &m); int i, j, k; int a[1003]; for (i = 0; i < n; i++) scanf("%d", &a[i]); int u, v; int d[1003][1003]; for (i = 0; i < n; i++) for (j = 0; j < n; j++) d[i][j] = 0; for (i = 0; i < m; i++) { scanf("%d %d", &u, &v); d[u - 1][v - 1] = d[v - 1][u - 1] = 1; } int f = 0; for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { for (k = j + 1; k < n; k++) { if (a[k] == a[i]) continue; if (a[i]a[k]) f++; if (a[i] > a[j] && a[j] < a[k]) f++; } } } if (f > 0) printf("YES\n"); else printf("NO\n"); return 0; }