#include <bits/stdc++.h>
using namespace std;
void codeforces_edu37_C() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int l[n];
  int r[n];
  char c[n];
  scanf("%s", c);
  int isGoing = 0;
  int len = 0;
  for (int i = 0; i < n - 1; i++) {
    if (c[i] == '1') {
      if (isGoing == 0) {
        isGoing++;
        l[len] = i;
        len++;
      }
    } else if (c[i] == '0') {
      if (isGoing == 1) {
        isGoing--;
        r[len - 1] = i;
      }
    }
  }
  if (isGoing == 1) {
    r[len - 1] = n - 1;
  }
  for (int i = 0; i < len; i++) {
    sort(a + l[i], a + r[i] + 1);
  }
  for (int j = 0; j < n; j++) {
    if (a[j] != j + 1) {
      printf("NO");
      return;
    }
  }
  printf("YES");
}
void codeforces_edu37_D() {}
void codeforces_edu37_E() {}
void codeforces_edu37_F() {}
void codeforces_edu37_G() {}
int main() {
  codeforces_edu37_C();
  return 0;
}
