#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  int mntmp = n + 1;
  int mxtmp = 0;
  int mx = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0') {
      mntmp = min(mntmp, a[i]);
      mxtmp = max(mxtmp, a[i]);
      if (mntmp < mx) {
        cout << "NO";
        return 0;
      }
      mx = mxtmp;
      mntmp = n + 1;
      mxtmp = 0;
    } else {
      mntmp = min(mntmp, a[i]);
      mxtmp = max(mxtmp, a[i]);
    }
  }
  mntmp = min(mntmp, a[n - 1]);
  mxtmp = max(mxtmp, a[n - 1]);
  if (mntmp < mx) {
    cout << "NO";
    return 0;
  }
  cout << "YES";
  return 0;
}
