#include <bits/stdc++.h>
using namespace std;
int a[200005];
char b[200005];
int pre[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%s", b + 1);
  int len = strlen(b + 1);
  for (int i = 1; i <= len; i++) {
    if (b[i] == '1')
      pre[i] = pre[i - 1] + 1;
    else
      pre[i] = pre[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    int l, r;
    if (a[i] != i) {
      l = min(i, a[i]);
      r = max(i, a[i]);
      if (pre[r - 1] - pre[l - 1] != abs(r - l)) {
        printf("NO\n");
        return 0;
      } else
        swap(a[i], a[a[i]]), i--;
    }
  }
  printf("YES\n");
  return 0;
}
