#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int N = 200100;
int n, a[N], q;
char al[N];
int b[N], temp[N], vis[N];
vector<int> id, val, adj[N];
void dfs(int u) {
  vis[u] = 1;
  val.push_back(a[u]);
  id.push_back(u);
  for (auto v : adj[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  scanf("%s", al);
  for (int i = 0; i < n - 1; i++) {
    if (al[i] == '1') {
      adj[i + 1].push_back(i + 2);
      adj[i + 2].push_back(i + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (al[i - 1] == '1' && !vis[i]) {
      dfs(i);
      sort(id.begin(), id.end());
      sort(val.begin(), val.end());
      for (int j = 0; j < id.size(); j++) {
        temp[id[j]] = val[j];
      }
      id.clear();
      val.clear();
    } else if ((i == n || al[i - 1] == '0') && !vis[i])
      temp[i] = a[i];
  }
  bool sol = 1;
  for (int i = 1; i <= n; i++) {
    if (temp[i] != b[i]) sol = 0;
  }
  if (!sol)
    printf("NO");
  else
    printf("YES");
  return 0;
}
