#include <bits/stdc++.h>
using namespace std;
int pre[200100];
int pos[200100];
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }
  string s;
  cin >> s;
  if (s[0] == '0') {
    pre[0] = 0;
  } else {
    pre[0] = 1;
  }
  for (int i = 1; i < n; i++) {
    if (s[i] == '0') {
      pre[i] = pre[i - 1];
    } else {
      pre[i] = pre[i - 1] + 1;
    }
  }
  int visited[n + 1];
  for (int i = 0; i < n; i++) {
    visited[arr[i]] = 23;
    if (arr[i] != i + 1 && visited[i + 1] != 23) {
      if (pre[pos[i + 1] - 1] - pre[i - 1] != pos[i + 1] - i) {
        std::cout << "NO" << endl;
        return 0;
      }
    }
  }
  std::cout << "YES" << endl;
}
