#include <bits/stdc++.h>
using namespace std;
int a[1000006], freq[1000006], vis[1000006];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[x] = i;
  }
  string s;
  cin >> s;
  s = '0' + s;
  for (int i = 1; i <= n; i++) freq[i] = freq[i - 1] + (s[i] == '1');
  for (int i = 1; i <= n; i++) {
    int x = min(i, a[i]);
    int y = max(i, a[i]);
    if (x == y) continue;
    if (freq[y - 1] - freq[x - 1] != y - x) return cout << "NO\n", 0;
  }
  cout << "YES\n";
  return 0;
}
