#include #include //#include using namespace std; typedef unsigned long int type; int main(){ while(true) { int days, money; cin >> days; if(days == 0) break; cin >> money; type * prices = new type [days]; for(int i = 0; i < days; i++) cin >> prices[i]; type maxProfit = 0, maxPrice = 0; for(int i = days; i--;) { const type price = prices[i]; if(maxPrice < price) maxPrice = price; const type numStocks = money / price; const type profit = numStocks * (maxPrice - price); if(profit > maxProfit) maxProfit = profit; } cout << maxProfit << endl; delete prices; } return 0; }