#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj(500005);
int visited[500005];
int counter;
void dfs(int node, int color) {
  counter++;
  visited[node] = color;
  for (int i = 0; i < adj[node].size(); ++i) {
    if (visited[adj[node][i]] == 0) dfs(adj[node][i], color);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    int n, val;
    cin >> n;
    vector<int> arr;
    for (int i = 0; i < n; ++i) {
      cin >> val;
      arr.push_back(val);
    }
    string s;
    cin >> s;
    vector<pair<int, int> > v;
    int flag = 0, start = -1, ender = -1;
    for (int i = 0; i < s.size(); ++i) {
      if (flag == 0 && s[i] == '0') continue;
      if (flag == 0 && s[i] == '1') {
        start = i;
        flag = 1;
        continue;
      }
      if (flag == 1 && s[i] == '0') {
        ender = i;
        v.push_back({start, ender});
        start = -1;
        ender = -1;
        flag = 0;
        continue;
      }
      if (flag == 1 && s[i] == '1') continue;
    }
    if (flag == 1) v.push_back({start, n - 1});
    vector<pair<int, int> >::iterator it;
    for (it = v.begin(); it != v.end(); ++it) {
      sort(arr.begin() + it->first, arr.begin() + it->second + 1);
    }
    flag = 0;
    for (int i = 1; i < n; ++i) {
      if (arr[i] <= arr[i - 1]) {
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      cout << "NO";
    else
      cout << "YES";
  }
  return 0;
}
