#include <bits/stdc++.h>
using namespace std;
int value[200009];
int pos[200009];
int main() {
  int n;
  cin >> n;
  int arr[n + 10];
  int ck = 0;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (i != arr[i]) {
      if (pos[arr[i]] == 1 && value[i] == 1) {
        cnt--;
        cnt--;
      } else if (pos[arr[i]] == 0 && value[i] == 0) {
        cnt = cnt + 2;
        pos[i] = 1;
        value[arr[i]] = 1;
      }
      if (pos[i] == 0) {
        pos[i] = 1;
      }
      if (value[arr[i]] == 0) {
        value[arr[i]] = 1;
      }
    }
    if (cnt > 0) {
      if (s[i - 1] == '0') {
        ck = 1;
        break;
      }
    }
  }
  if (ck == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
