#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long n;
long long v[200005];
string s;
long long bit[200005];
void update(long long x, long long v) {
  while (x < 200005) {
    bit[x] += v;
    x += (x & -x);
  }
}
long long query(long long x) {
  long long sum = 0;
  while (x > 0) {
    sum += bit[x];
    x -= (x & -x);
  }
  return sum;
}
long long pos[4 * 200005];
long long xdxd[200005];
void build(long long no, long long i, long long j) {
  if (i == j)
    pos[no] = xdxd[i];
  else {
    long long esq = no * 2, dir = no * 2 + 1;
    long long meio = (i + j) / 2;
    build(esq, i, meio);
    build(dir, meio + 1, j);
    pos[no] = min(pos[esq], pos[dir]);
  }
}
long long queryPos(long long no, long long i, long long j, long long a,
                   long long b) {
  if (a <= i && j <= b) return pos[no];
  if (i > b || a > j) return -1;
  long long esq = 2 * no, dir = 2 * no + 1;
  long long meio = (i + j) / 2;
  long long queryEsq = queryPos(esq, i, meio, a, b);
  long long queryDir = queryPos(dir, meio + 1, j, a, b);
  if (queryEsq == -1) return queryDir;
  if (queryDir == -1) return queryEsq;
  return min(queryDir, queryEsq);
}
int32_t main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> v[i];
    xdxd[v[i]] = i;
  }
  build(1, 1, n);
  cin >> s;
  for (long long i = 1; i < n; i++) {
    if (s[i - 1] == '1') {
      update(i, 1);
    }
  }
  bool ver = true;
  for (long long i = 2; i <= n; i++) {
    if (v[i] == n) continue;
    long long minIdx = queryPos(1, 1, n, v[i] + 1, n);
    if (minIdx > i) continue;
    long long sz = query(i - 1) - query(minIdx - 1);
    if (sz < i - minIdx) ver = false;
  }
  cout << (ver ? "YES" : "NO") << '\n';
  return 0;
}
