#include <bits/stdc++.h>
using namespace std;
int arr[300000];
int coun[300000];
string s;
int main() {
  int n, j;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  cin >> s;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == '1')
      coun[i] = 1;
    else
      coun[i] = 0;
  }
  for (int i = 0; i < n - 1; i++) {
    if (coun[i] == 1) {
      for (j = i; j < n - 1; j++) {
        if (coun[j] != 1) break;
      }
      sort(arr + i, arr + j + 1);
      i = j;
    }
  }
  bool f = true;
  for (int i = 0; i < n; i++)
    if (arr[i] != (i + 1)) f = false;
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
