#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mod = 1e9 + 7;
int N;
string s;
vector<int> a;
vector<int> used(200010, 0);
vector<int> pos(200010);
int cnt = 1;
void dfs(int v) {
  used[v] = cnt;
  if (v == N) return;
  if (s[v] == '1') {
    dfs(v + 1);
  }
}
void slv() {
  cin >> N;
  a.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  cin >> s;
  s = " " + s;
  for (int i = 1; i < N; i++) {
    if (s[i] == '1' && used[i] == 0) {
      dfs(i);
      cnt++;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (a[i] == i) continue;
    if (pos[i] < i && used[pos[i]] != used[i]) {
      cout << "NO";
      return;
    } else if (pos[i] > i && used[pos[i]] != used[i]) {
      cout << "NO";
      return;
    }
    if (used[pos[i]] == 0 && used[i] == 0) {
      cout << "NO";
      return;
    }
  }
  cout << "YES";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  while (T--) slv();
  return 0;
}
