#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> vec;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vec.push_back(a);
  }
  string x;
  cin >> x;
  int start = -1;
  if (x[0] == '1') start = 0;
  for (int i = 1; i < n; i++) {
    if (start == -1) {
      if (x[i] == '1') start = i;
      continue;
    }
    if (x[i] == '1') continue;
    sort(vec.begin() + start, vec.begin() + i + 1);
    start = -1;
  }
  if (start != -1) sort(vec.begin() + start, vec.end());
  bool good = true;
  for (int i = 1; i < n; i++) good &= vec[i] >= vec[i - 1];
  if (good)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
