#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<int> A(n + 2), N(n + 2);
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 1; i <= m; i++) cin >> N[i];
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      vector<int> H(n + 2);
      for (int k = i; k <= j; k++) H[A[k]]++;
      if (H == N) return cout << "YES\n", 0;
    }
  cout << "NO\n";
}
