#include <bits/stdc++.h>
using namespace std;
int n, i, a[200001], B[200001], b, j, c, fix[200001];
string s;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> s;
  for (i = 0; i < n - 1; i++)
    if (s[i] == '1') B[i + 1] = 1;
  for (i = 1; i <= n; i++)
    if (B[i] == 0) {
      if (B[i - 1] == 0) {
        if (a[i] != i) {
          cout << "NO";
          return 0;
        }
      } else {
        fix[a[i]] = 1;
        b = i;
        for (j = c; j <= b; j++)
          if (fix[j] == 0) {
            cout << "NO";
            return 0;
          }
      }
    } else {
      fix[a[i]] = 1;
      if (B[i - 1] == 0) c = i;
    }
  cout << "YES";
}
