#include <bits/stdc++.h>
using namespace std;
vector<long long> parent;
vector<long long> urank;
void create(long long x) {
  parent[x] = x;
  urank[x] = 0;
}
long long find(long long x) {
  if (parent[x] != x) {
    parent[x] = find(parent[x]);
  }
  return parent[x];
}
void merge(long long x, long long y) {
  long long xroot = find(x);
  long long yroot = find(y);
  if (urank[xroot] <= urank[yroot]) {
    parent[xroot] = yroot;
    urank[yroot] = urank[yroot] + urank[xroot];
  } else {
    parent[yroot] = xroot;
    urank[xroot] = urank[xroot] + urank[yroot];
  }
}
bool poss = 1;
bool cmp(int a, int b) {
  if (a > b) {
    return a < b;
  }
  if (find(a) != find(b)) {
    poss = 0;
  }
  return a < b;
}
int main() {
  int n;
  cin >> n;
  vector<int> a;
  parent = vector<long long>(200001);
  urank = vector<long long>(200001);
  for (int i = 0; i < n; i++) {
    int u;
    cin >> u;
    a.push_back(u);
    create(u);
  }
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      merge(a[i], a[i + 1]);
    }
  }
  stable_sort(a.begin(), a.end(), cmp);
  if (poss) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}
