#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
char s[N];
int a[N];
int ma[N];
bool check(int k, int l, int r) {
  while (l <= r) {
    int mid = (l + r) / 2;
    if (k == mid)
      return true;
    else if (k < mid)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  cin >> (s + 1);
  for (int i = 1; i < n; i++) {
    if (s[i] == '0') {
      if (a[i] != i) {
        cout << "NO" << endl;
        return 0;
      } else
        continue;
    }
    int j = i - 1;
    while (s[j + 1] == '1') {
      j++;
    }
    for (int k = i; k <= j + 1; k++) {
      if (!check(a[k], i, j + 1)) {
        cout << "NO" << endl;
        return 0;
      }
    }
    i = j + 1;
  }
  cout << "YES" << endl;
}
