#include <bits/stdc++.h>
using namespace std;
char s[101];
int main() {
    int n;
    while(scanf("%d",&n),n) {
        vector<int> key;
        for(int i=0;i<n;i++) {
            int k;
            scanf("%d",&k);
            key.push_back(k);
        }
       scanf("%s",s);
       for(int i=0;s[i]!='\0';i++) {
            int code=0;
            if('a'<=s[i]&&s[i]<='z') code=s[i]-'a';
            if('A'<=s[i]&&s[i]<='Z') code=26+s[i]-'A';
            code-=key[i%key.size()];
            while(code<0) code+=52;
            code%=52;
            if(0<=code&&code<=25) putchar('a'+code);
            if(26<=code&&code<=51) putchar('A'+code-26);
       }
       putchar('\n');
    }
}
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n+m){
    vector<int>ve(n);
    ll ans=0;
    for(int i=0;i<n;i++){
      cin>>ve[i];ans+=ve[i];
    }
    sort(ve.begin(),ve.end(),greater<int>());
    for(int i=m-1;i<n;i+=m)
      ans-=ve[i];
    cout<<ans<<endl;
  }
  return 0;
}

