#include <bits/stdc++.h>
const int N = (int)(5e5) + 322;
const long long INF = (long long)(1e9) + 7;
const double eps = (1e-9);
using namespace std;
int n, m, k, kol, q, iter, cur, ans[1111], pref[N], a[N];
char ch[N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n - 1; ++i) {
    cin >> ch[i];
    pref[i] = pref[i - 1] + (ch[i] - '0');
  }
  for (int i = 1; i <= n; ++i) {
    if (i != a[i]) {
      int l = min(i, a[i]), r = max(i, a[i]);
      if (pref[r - 1] - pref[l - 1] != r - l) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
}
