#include <bits/stdc++.h>   using namespace std;   int main() {     map<int, int> m;     string s;     int n, a;     cin >> n >> s;     for (int i = 1; i < 10; ++i) {       cin >> a;       m[i] = a;     }     for (int i = 0; i < n; ++i) {       if (s[i] -  0  < m[s[i] -  0 ]) {         while (s[i] -  0  <= m[s[i] -  0 ]) {           s[i] =  0  + m[s[i] -  0 ];           ++i;         }         break;       }     }     cout << s;     return 0;   }   