#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll int n,a; cin>>n;
string s,p; ll int maxx = 0;
for(int i=1;i<=n;i++)
{
cin>>a;
maxx = max(a,maxx);
if(maxx==i) s.push_back('0'); else s.push_back('1'); // creating an optimal solution
}
s.pop_back(); // removing last element
cin>>p; bool flag = 1;
ll int j = 0;
for(auto x :p) // checking if p is subset of s
{
if(s[j]=='1'&&x=='0')
flag = 0;
j++;
}
if(flag) cout<<"YES";
else cout<<"NO";
}