int c[maxn], cnt; voidinit_hash(){ for (int i = 1; i <= n; ++i) c[i] = (a[i] -= i); sort(c + 1, c + n + 1); cnt = unique(c + 1, c + n + 1) - c - 1; for (int i = 1; i <= n; ++i) a[i] = lower_bound(c + 1, c + cnt + 1, a[i]) - c; }
int d[maxn], len;
int ans; intmain(){ cin >> n >> m; n += 2; m += 2; a[1] = -INF; a[n] = INF; b[1] = 1; b[m] = n; for (int i = 2; i < n; ++i) cin >> a[i]; for (int i = 2; i < m; ++i) cin >> b[i], ++b[i]; init_hash(); for (int i = 2; i <= m; ++i) { if (a[b[i - 1]] > a[b[i]]) returnputs("-1"), 0; len = 0; int l = b[i - 1], r = b[i]; for (int j = l; j <= r; ++j) { if (a[j] < a[l] || a[j] > a[r]) continue; if (a[j] >= d[len]) d[++len] = a[j]; else *upper_bound(d + 1, d + len + 1, a[j]) = a[j]; } ans += (r - l + 1) - len; } cout << ans << endl; return0; }