#include int main() { int pocet, konto; int pole[70000]; scanf("%d", &pocet); while(pocet != 0) { scanf("%d", &konto); for(int i = 0; i < pocet; i++) { scanf("%d", &pole[i]); } int r_max = 4001; int max, min; int profit = 0; int a_profit = 0; int a_i = 0; do { min = 40000; max = 0; for(int i = 1; i < pocet; i++) { if(pole[i] > max && pole[i] < r_max) { max = pole[i]; a_i = i; } } for(int i = 0; i < a_i; i++) { if(pole[i] < min) { min = pole[i]; } } //printf("min:%d max:%d\n", min, max); if( max > min ) { a_profit = (konto / min) * max - konto + (konto % min); } if(a_profit > profit) profit = a_profit; //printf("profit = %d\n", profit); r_max = max; } while( max > min); printf("%d\n", profit); scanf("%d", &pocet); } return 0; }