#include <bits/stdc++.h>
using namespace std;
void seive(int n) {
  bool prim[n + 1];
  memset(prim, true, sizeof(prim));
  for (int i = 2; i <= n; i++) {
    if (prim[i]) {
      for (int j = i * 2; j <= n; j += i) prim[j] = false;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (prim[i]) cout << i << "\n";
  }
}
int bin_search(int arr[], int low, int high, int val) {
  while (high >= low) {
    int mid = (high + low) / 2;
    if (arr[mid] == val) return mid;
    if (arr[mid] > val)
      high = mid - 1;
    else
      low = mid + 1;
  }
  return -1;
}
int modpow(int x, int n, int m) {
  if (n == 0) return 1 % m;
  int u = modpow(x, n / 2, m);
  u = (u * u) % m;
  if (n % 2) u = (u * x) % m;
  return u;
}
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (long long i = 0, _n = (n); i < _n; i++) cin >> arr[i];
  int pp[n];
  pp[0] = 0;
  string s;
  cin >> s;
  for (long long i = 0, _n = (n - 1); i < _n; i++) {
    if (s[i] == '1')
      pp[i + 1] = 1 + pp[i];
    else
      pp[i + 1] = pp[i];
  }
  for (long long i = 0, _n = (n); i < _n; i++) {
    if (arr[i] != i + 1) {
      if (arr[i] > i + 1) {
        if ((pp[arr[i] - 1] - pp[i]) != (arr[i] - i - 1)) {
          cout << "NO";
          return 0;
        }
      } else {
        if ((pp[i - 1] - pp[arr[i] - 1]) != (i - arr[i])) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
  return 0;
}
