#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long n, i, j, k, l, r, c = 0;
    cin >> n;
    long long v[n], f[n], fg = 0;
    for (i = 0; i < n; i++) cin >> v[i];
    string s;
    cin >> s;
    s += '0';
    for (i = 0; i < n; i++) f[i] = s[i] - '0';
    vector<long long> pos(200005, 0);
    vector<long long> num(200005, 0);
    for (i = 0; i < n; i++) {
      if (fg == 0) {
        if (f[i] == 0) {
          pos[i + 1] = c;
          num[v[i]] = c;
          c++;
        } else {
          fg = 1;
          pos[i + 1] = c;
          num[v[i]] = c;
        }
      } else {
        if (f[i] == 0) {
          pos[i + 1] = c;
          num[v[i]] = c;
          c++, fg = 0;
        } else {
          pos[i + 1] = c, num[v[i]] = c;
        }
      }
    }
    for (i = 1; i <= n; i++) {
      if (pos[i] != num[i]) {
        cout << "NO";
        return 0;
      }
    }
    cout << "YES";
  }
  return 0;
}
