#include <bits/stdc++.h>
using namespace std;
int num[200005], q[200005];
char s[200005];
int main() {
  int n, ant = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  scanf("%s", s + 1);
  for (int i = 1; i <= n - 1; i++) {
    if (s[i] == '1') ant++;
    q[i] = ant;
  }
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    if (num[i] != i) {
      if (num[i] > i) {
        int r = num[i] - i;
        if (r != (q[num[i] - 1] - q[i - 1])) {
          flag = false;
          break;
        }
      } else {
        int r = i - num[i];
        if (r != (q[i - 1] - q[num[i] - 1])) {
          flag = false;
          break;
        }
      }
    }
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
