#include <bits/stdc++.h>
using namespace std;
int Min(int aa, int bb) { return aa < bb ? aa : bb; }
int Max(int aa, int bb) { return aa > bb ? aa : bb; }
struct hh {
  int aaa, bbb;
} cc[200005];
char ss[200005];
bool cmp(hh xa, hh ya) { return xa.aaa < ya.aaa; };
int main() {
  int n, a[200005], cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%s", ss);
  for (int i = 1; i <= n; i++)
    if (a[i] != i) {
      cc[++cnt].aaa = Min(i, a[i]);
      cc[cnt].bbb = Max(i, a[i]);
    }
  int lst = 0;
  sort(cc + 1, cc + 1 + cnt, cmp);
  for (int i = 1; i <= cnt; i++) {
    lst = Max(lst, cc[i].aaa);
    for (; lst < cc[i].bbb; lst++) {
      if (ss[lst - 1] == '0') {
        printf("NO");
        return 0;
      }
    }
  }
  printf("YES");
  return 0;
}
