#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 7, inf = 1e9 + 7;
int a[M];
vector<int> g[M];
bool is[M];
int cnt, mx;
void dfs(int u) {
  is[u] = true;
  cnt++;
  mx = max(mx, a[u]);
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (!is[v]) dfs(v);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '1') continue;
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  int tot = 0;
  for (int i = 0; i < n; i++) {
    if (is[i]) continue;
    cnt = 0, mx = INT_MIN;
    dfs(i);
    if (tot + cnt < mx) cout << "NO" << endl, exit(0);
    tot += cnt;
  }
  cout << "YES" << endl;
}
