#include <bits/stdc++.h>
using namespace std;
int arr[200003];
int main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  string s;
  cin >> s;
  s += '0';
  int start = -1;
  int len = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      if (start == -1) start = i;
      len++;
    } else {
      if (start != -1) {
        sort(arr + start, arr + start + len);
        start = -1;
        len = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i + 1 != arr[i]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "\n";
  cout << "YES\n";
  return 0;
}
