#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 9;
int req_pos[N];
int cnt[N];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  int sk;
  for (int i = 1; i <= n; i++) {
    cin >> sk;
    req_pos[sk] = i;
  }
  char l;
  for (int i = 1; i < n; i++) {
    cin >> l;
    cnt[i] = (l == '0');
    cnt[i] += cnt[i - 1];
  }
  cnt[n] = cnt[n - 1];
  int lef, rig;
  for (int i = 1; i <= n; i++) {
    lef = i;
    rig = req_pos[i];
    if (rig < lef) swap(lef, rig);
    if (lef == rig) continue;
    if (cnt[rig - 1] - cnt[lef - 1] > 0) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
