#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
int n;
vector<int> a;
vector<bool> canC;
bool ans;
void input() {
  cin >> n;
  int tmp;
  for (int((i)) = (0); ((i)) < ((n)); ((i))++) {
    cin >> tmp;
    a.push_back(tmp - 1);
  }
  string str;
  cin >> str;
  for (auto c : str) {
    if (c == '1')
      canC.push_back(true);
    else
      canC.push_back(false);
  }
  ans = true;
}
void exec() {
  int big = 0;
  for (int((i)) = (0); ((i)) < ((n - 1)); ((i))++) {
    big = max(big, a[i]);
    if (canC[i]) {
      continue;
    } else {
      if (big > i) {
        ans = false;
        goto end;
      } else {
        big = 0;
      }
    }
  }
end:;
}
void output() { cout << (ans ? "YES" : "NO") << endl; }
void debug() {
  int N;
  cin >> N;
}
int main() {
  input();
  exec();
  output();
  debug();
  return 0;
}
