#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  int l = 0;
  int r = 0;
  while (l < n - 1 && r < n - 1) {
    if (s[r] == '1')
      r++;
    else {
      for (int i = l; i <= r; i++) {
        if (a[i] <= l || a[i] > r + 1) {
          cout << "NO";
          return;
        }
      }
      r++;
      l = r;
    }
  }
  for (int i = l; i <= r; i++) {
    if (a[i] <= l || a[i] > r + 1) {
      cout << "NO";
      return;
    }
  }
  cout << "YES";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) solve();
}
