#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int n, a[N + 10], b[N + 10];
char s[N + 10];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> (s + 1);
  for (int i = 1; i <= n - 1; i++)
    if (s[i] == '1') {
      int j = i;
      while (j + 1 <= n - 1 && s[j + 1] == s[i]) j++;
      sort(a + i, a + 1 + j + 1);
      i = j;
    }
  for (int i = 1; i <= n; i++)
    if (a[i] != i) return cout << "NO" << endl, 0;
  cout << "YES" << endl;
  return 0;
}
