#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
const int N = 2e5 + 100;
int v[N];
int main() {
  int n;
  ios::sync_with_stdio(false);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> v[i];
  ;
  string s;
  cin >> s;
  vector<vector<int> > comp;
  vector<int> at;
  for (int i = 0; i < s.size(); i++) {
    at.push_back(v[i]);
    if (s[i] == '0') {
      comp.push_back(at);
      at.clear();
    }
  }
  for (int i = 0; i < comp.size(); i++) sort(comp[i].begin(), comp[i].end());
  int cnt = 1;
  for (int i = 0; i < comp.size(); i++)
    for (int j = 0; j < comp[i].size(); j++) {
      if (comp[i][j] != cnt) {
        cout << "NO" << endl;
        return 0;
      } else {
        cnt++;
      }
    }
  cout << "YES" << endl;
  return 0;
}
