#include <bits/stdc++.h>
using namespace std;
int a[2000001];
int main() {
  int n, i, o, x, j;
  string s;
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> x, a[x] = i;
  cin >> s;
  int p = -1;
  for (i = 0; i < s.length(); ++i) {
    if (s[i] == '0') {
      for (j = i; j > p; --j) {
        if (a[j + 1] > i + 1) {
          cout << "NO";
          return 0;
        }
      }
      p = i;
    }
  }
  cout << "YES";
  return 0;
}
