#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
int n, a[maxn], l[maxn], r[maxn];
string str;
struct node {
  int id, x;
} g[maxn];
bool cmp(struct node a, struct node b) { return a.x < b.x; }
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; i++) scanf("%d", &g[i].x), g[i].id = i;
    cin >> str;
    int flag = 0;
    l[0] = g[0].x;
    r[n - 1] = g[n - 1].x;
    for (int i = 1; i < n; i++) l[i] = max(g[i].x, l[i - 1]);
    for (int i = n - 2; i >= 0; i--) r[i] = min(g[i].x, r[i + 1]);
    for (int i = 0; i < n - 1; i++) {
      if (str[i] == '1') continue;
      if (str[i] == '0') {
        if (r[i + 1] < l[i]) {
          flag = 1;
          break;
        }
      }
    }
    if (flag)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
