#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, l, r, x = 1, c = 1;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long max = a[0];
  string str;
  cin >> str;
  for (long long i = 1; i <= n; ++i) {
    if (a[i - 1] > max) max = a[i - 1];
    if (str[i - 1] == '0') {
      if (i < max) {
        c = 0;
        break;
      }
    }
  }
  if (c) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
