#include <bits/stdc++.h>
using namespace std;
long long n;
long long one, two;
vector<long long> v(200003);
long long i, j;
bool is_one;
vector<long long> stck;
vector<long long> result;
string str;
int main() {
  cin >> n;
  for (i = 0; i < n; i += 1) {
    cin >> v[i];
  }
  is_one = false;
  string str;
  cin >> str;
  for (i = 0; i < n; i += 1) {
    if (str[i] == '0') {
      if (is_one) {
        stck.push_back(v[i]);
        is_one = false;
        if (stck.size() > 0) {
          sort(stck.begin(), stck.end());
          reverse(stck.begin(), stck.end());
          while (stck.size()) {
            result.push_back(stck.back());
            stck.pop_back();
          }
        }
      } else {
        result.push_back(v[i]);
      }
    } else {
      is_one = true;
      stck.push_back(v[i]);
    }
  }
  if (stck.size() > 0) {
    sort(stck.begin(), stck.end());
    reverse(stck.begin(), stck.end());
    while (stck.size() > 0) {
      result.push_back(stck.back());
      stck.pop_back();
    }
  }
  for (i = 1; i < n; i += 1) {
    if (result[i] <= result[i - 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
