#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 = 40001; int r_min = 0; int max, min; int profit = 0; int a_profit = 0; int a_i = 0; do { min = 40001; 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]; } } if( max > min ) { a_profit = (konto / min) * max - konto + (konto % min); } if(a_profit > profit) profit = a_profit; r_max = max; if(min > r_min) r_min = min; } while( max*konto > profit && a_i != pocet - 1 ); printf("%d\n", profit); scanf("%d", &pocet); } return 0; }