#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long arr[n];
  set<long long> st;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  string s;
  cin >> s;
  s += '0';
  long long prev = -1, previ = -1;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '0') {
      if (previ != -1) {
        for (long long j = previ; j <= i; j++) st.insert(arr[j]);
        long long j = previ;
        for (long long e : st) arr[j++] = e;
        st.clear();
        previ = -1;
      }
    } else {
      if (previ == -1) previ = i;
    }
  }
  vector<long long> oth(arr, arr + n);
  sort(oth.begin(), oth.end());
  bool pos = true;
  for (long long i = 0; i < n; i++)
    if (oth[i] != arr[i]) pos = false;
  if (pos)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
