#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7f7f7f7f;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
vector<int> arr;
int main() {
  int n;
  string st;
  int x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    arr.push_back(x);
  }
  cin >> st;
  int beg = 0;
  int flag = 0;
  for (int i = 0; i < st.size(); i++) {
    if (st[i] == '1' && flag == 0) {
      beg = i;
      flag = 1;
    } else if (st[i] == '0') {
      if (flag) {
        sort(arr.begin() + beg, arr.begin() + i + 1);
        flag = 0;
        beg = -1;
      }
    }
  }
  if (flag == 1) sort(arr.begin() + beg, arr.end());
  bool f = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] != i + 1) {
      f = 1;
      break;
    }
  }
  if (f == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
