#include <stdio.h>

int main(void){
	int n, a[100], i, j;
	char c, s[53] = {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
	while(1){
		scanf("%d",&n);
		if(!n) break;
		for(i = 0;i < n;i++)
			scanf("%d",&a[i]);
		getchar();
		for(i = 0;(c = getchar()) != '\n';i++){
			for(j = 0;j < 52;j++){
				if(s[j] == c)
					printf("%c",s[(52 + j - a[i % n]) % 52]);
			}
		}
		printf("\n");
	}
	return 0;
}
#include<iostream>

int main(){
	int e;
	while(1){
		std::cin >> e;
		if(!e)break;
		int m = 1000001;
		for(int i=0;i*i*i<=e;i++){
			for(int ii=0;i*i*i + ii*ii<=e;ii++){
				int x = e-i*i*i-ii*ii;
				int tmp = i+ii+x;
				if(tmp < m) m = tmp;
			}
		}
		std::cout << m << std::endl;
	}
	return 0;
}