#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 7;
int n, nums[N], diff[N];
char orgDiff[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", nums + i);
  }
  scanf("%s", orgDiff + 1);
  for (int i = 1; i < n; ++i) {
    int low = min(i, nums[i]);
    int high = max(i, nums[i]);
    diff[low]++, diff[high]--;
  }
  int curr = 0;
  for (int i = 1; i < n; ++i) {
    curr += diff[i];
    if (curr > 0 && orgDiff[i] != '1') {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}
