#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  vector<long long> v, v1;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == '1') {
      v.push_back(a[i]);
      v1.push_back(i);
    }
    if (v.size() >= 1 && s[i] == '0') {
      v1.push_back(i);
      v.push_back(a[i]);
      sort(v.begin(), v.end());
      for (int j = 0; j < v.size(); j++) {
        a[v1[j]] = v[j];
      }
      v.clear();
      v1.clear();
    }
  }
  if (s[n - 2] == '1') {
    v1.push_back(n - 1);
    v.push_back(a[n - 1]);
    sort(v.begin(), v.end());
    for (int j = 0; j < v.size(); j++) {
      a[v1[j]] = v[j];
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i + 1] < a[i]) return cout << "No", 0;
  }
  cout << "YES";
  return 0;
}
