#include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 4, NN = 2e5 + 3, inf = 1e9 + 7;
long long const md = 998244353;
long long a[N], b[N], n, l, r, k, m, x, bbp, kk, sz, ans;
long long dp[N], q, qq;
char ch;
bool us[N];
map<string, long long> mp;
string second, ss, t;
vector<pair<long long, long long> > ot;
vector<long long> v;
pair<long long, long long> p[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[a[i]] = i;
  }
  cin >> second;
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    if (second[i - 1] == '1') dp[i]++;
  }
  for (int i = 1; i <= n; i++) {
    if (b[i] < i) continue;
    if (dp[b[i] - 1] - dp[i - 1] < b[i] - i) return cout << "NO", 0;
  }
  cout << "YES";
  return 0;
}
