public static void solve(int inicial, String rates) {
		Scanner sc = new Scanner(rates);
		long res = inicial;
		long coins = 0;
		boolean n = false;
		
		int a = sc.nextInt();
		while(sc.hasNext()) {
			n = false;
			int b = sc.nextInt();
			if(a<b) {
				coins = res/a;
				if(sc.hasNext()) {
					while(sc.hasNext()) {
						a = b;
						b = sc.nextInt();
						if(a>b) {
							n = true;
							res = coins*a;
							a = b;
							break;
						}
					}
					if (!n) { // Last one in list
						res = coins*b;
					}
				}
				else {
					res = coins*b;
				}
			} else {
				a = b;
			}
		}
		sc.close();
		
		System.out.println(res);
	}