#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
int cnt[200007], idx[200007];
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 1];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    idx[a[i]] = i;
  }
  string s;
  cin >> s;
  s = "#" + s;
  for (int i = 1; i < s.size(); i++) {
    cnt[i] = cnt[i - 1] + (s[i] - '0');
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == i) continue;
    int lo = min(i, min(idx[a[i]], idx[i])),
        hi = max(i, max(idx[a[i]], idx[i]));
    if (lo > hi) swap(lo, hi);
    if ((cnt[hi - 1] - cnt[lo - 1]) != (hi - lo)) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
