#include <bits/stdc++.h>
std::priority_queue<int> q;
struct node {
  int val, id;
} a[200005];
bool comp(node a, node b) { return a.val < b.val; }
int n, p[200005], b[200005];
char s[200005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i].val), a[i].id = i, b[i] = a[i].val;
  std::sort(a + 1, a + 1 + n, comp);
  for (int i = 1; i <= n; i++) p[a[i].val] = i;
  scanf("%s", s + 1);
  for (int i = 1; i < n; i++) {
    if (s[i] == '1')
      q.push(p[b[i]]);
    else {
      q.push(p[b[i]]);
      while (!q.empty() && q.top() > i) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
}
