#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using P = pair<int, int>;   constexpr int INF = 1001001001;   constexpr int mod = 1000000007;   template <class T>   inline bool chmax(T& x, T y) {     if (x < y) {       x = y;       return true;     }     return false;   }   template <class T>   inline bool chmin(T& x, T y) {     if (x > y) {       x = y;       return true;     }     return false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n, k;     cin >> n >> k;     vector<int> a(n + 2), ban(k + 2);     a[0] = -1e+7, a[n + 1] = INF;     ban[0] = 0, ban[k + 1] = n + 1;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       a[i] -= i;     }     for (int i = 1; i <= k; ++i) cin >> ban[i];     int ans = 0;     for (int i = 0; i <= k; ++i) {       int lb = a[ban[i]], ub = a[ban[i + 1]];       if (ub - lb < 0) {         cout << -1 << endl;         return 0;       }       vector<int> vals;       int cnt = 0;       int s = ban[i] + 1, t = ban[i + 1];       for (int j = s; j < t; ++j) {         if (a[j] < lb || a[j] > ub)           ++cnt;         else           vals.emplace_back(a[j]);       }       int m = vals.size();       vector<int> dp(m, INF);       for (int j = 0; j < m; ++j) {         *upper_bound(dp.begin(), dp.end(), vals[j]) = vals[j];       }       cnt += dp.end() - lower_bound(dp.begin(), dp.end(), INF);       ans += cnt;     }     cout << ans << endl;   }   