#include <bits/stdc++.h>
using namespace std;
bool vowel(char a) {
  a = toupper(a);
  if ((a == 'A') || (a == 'E') || (a == 'I') || (a == 'O') || (a == 'U'))
    return 1;
  return 0;
}
long long int n, m, q, a, b, c, sum = 0, cnt = 0;
long long int arr[2000005];
map<long long int, bool> mp;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i]--;
  }
  cin >> s;
  long long int mn = 20000051, mx = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      if (arr[i] != i) {
        cout << "NO" << endl;
        return 0;
      }
    } else if (s[i] == '1') {
      mn = 20000051, mx = 0;
      int st = i;
      mn = min(arr[i], mn);
      mx = max(arr[i], mx);
      while (i < n && s[i] == '1') {
        mn = min(arr[i + 1], mn);
        mx = max(arr[i + 1], mx);
        i++;
      }
      if (mn != st || mx != i) {
        cout << "NO" << endl;
        return 0;
      }
      arr[i] = mx;
    }
  }
  cout << "YES" << endl;
}
