#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[200005];
  int n;
  string str;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  cin >> str;
  bool f1;
  int s, e;
  for (int i = 0; i < n; i++) {
    if (f1 == 0 && str[i] == '1') {
      f1 = 1;
      s = i;
    }
    if (f1 && (str[i] == '0' || str[i] == '\0')) {
      e = i;
      f1 = 0;
      sort(arr + s, arr + e + 1);
    }
  }
  bool f2 = 0;
  for (int i = 0; i < n; i++)
    if (arr[i] != i + 1) f2 = 1;
  if (f2)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
