#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> v[N];
int a[N];
int b[N];
bool vis[N];
vector<int> u, w;
void dfs(int s) {
  vis[s] = true;
  u.push_back(s);
  w.push_back(a[s]);
  for (int i = 0; i < v[s].size(); i++) {
    if (!vis[v[s][i]]) {
      dfs(v[s][i]);
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  int l = n - 1;
  for (int i = 0; i < l; i++) {
    if (s[i] == '1') {
      v[i + 1].push_back(i + 2);
      v[i + 2].push_back(i + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    u.clear();
    w.clear();
    if (!vis[i]) {
      dfs(i);
      sort(u.begin(), u.end());
      sort(w.begin(), w.end());
      int yo = u.size();
      for (int i = 1; i <= yo; i++) {
        b[u[i - 1]] = w[i - 1];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != b[i]) {
      return cout << "NO", 0;
    }
  }
  cout << "YES";
  return 0;
}
