#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
int arr[MAX_N];
bool swappable[MAX_N];
int n;
int lo[MAX_N];
int hi[MAX_N];
int sufflo[MAX_N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
      swappable[i] = 0;
    else
      swappable[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    lo[i] = 1000000000;
    hi[i] = -1000000000;
  }
  int comp = 0;
  for (int i = 0; i < n; i++) {
    lo[comp] = min(lo[comp], arr[i]);
    hi[comp] = max(hi[comp], arr[i]);
    while (i < n - 1 && swappable[i]) {
      i++;
      lo[comp] = min(lo[comp], arr[i]);
      hi[comp] = max(hi[comp], arr[i]);
    }
    comp++;
  }
  sufflo[comp - 1] = lo[comp - 1];
  for (int i = (comp - 1) - 1; i >= 0; i--)
    sufflo[i] = min(lo[i], sufflo[i + 1]);
  for (int i = 0; i < comp - 1; i++) {
    if (hi[i] > sufflo[i + 1]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}
