#include <bits/stdc++.h>
using namespace std;
long long p[200005];
long long a[200005];
long long n;
string s;
long long findset(long long x) { return p[x] == x ? x : p[x] = findset(p[x]); }
void unionset(long long x, long long y) {
  x = findset(x);
  y = findset(y);
  p[y] = x;
}
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) p[i] = i;
  cin >> s;
  s = "#" + s;
  for (long long i = 1; i <= n - 1; i++) {
    if (s[i] == '1') {
      unionset(i, i + 1);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (findset(a[i]) == findset(i)) continue;
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  return 0;
}
