#include <vector>
#include <algorithm>
#include <iostream>
#include <climits>
using namespace std;
typedef long long int int64;

vector<int64> P,Q;
int64 N,M,T;

int main(void)
{
	while(true)
	{
		N = 0;
		M = 0;
		P.clear();
		Q.clear();
		P.shrink_to_fit();
		Q.shrink_to_fit();
		cin >> N >> M;
		if(N == 0 && M == 0)
		{
			exit(0);
		}
		for(int i = 0;i < N;i++)
		{
			cin >> T;
			P.push_back(T);
		}
		P.push_back(0);
		for(auto itr = P.begin();itr < P.end();itr++)
		{
			for(auto itr2 = P.begin();itr2 < P.end();itr2++)
			{
				Q.push_back(*itr + *itr2);
			}
		}
		Q.push_back(LLONG_MAX / 2);
		Q.push_back(LLONG_MIN / 2);
		sort(Q.begin(),Q.end());
		int64 ms = 0;
		for(auto itr = Q.begin();itr < Q.end()+1;itr++)
		{
			ms = max(ms,*itr + *(lower_bound(Q.begin(),Q.end() - 1,M-*itr+1) - 1));
		}
		cout << ms << endl;
	}
}
#include <iostream>
#include <vector>
#include <string>
using namespace std;

char Decryption(int k, char s) {
  char station[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
                    'n','o','p','q','r','s','t','u','v','w','x','y','z',
                    'A','B','C','D','E','F','G','H','I','J','K','L','M',
                    'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  int num;

  for(int i = 0; i < 52; i++) {
    if(s >= 'a' && s <= 'z')
      num = s - 'a';
    else
      num = s - 39;
  }
  return station[(52 + num - k) % 52];
}

int main() {
  vector<int> K;
  int n;
  string s_in;
  string s_out;

  while(1) {
    cin >> n;
    if(n == 0)
      break;

    for(int i = 0; i < n; i++) {
      int k;
      cin >> k;
      K.push_back(k);
    }

    cin >> s_in;

    for(int i = 0; i < s_in.size(); i++) {
      s_out += Decryption(K[i%n], s_in[i]);
    }

    cout << s_out << endl;

    s_out.erase();
    K.clear();
  }
  return 0;
}

