public int optimalPrice(int[] price, int[] cost) {
		int max = 0;
		int max_price = 0;
		for (int i = 0; i < price.length; i++) {
			int sumGain = 0;
			for (int j = 0; j < price.length; j++) {
				if (price[j] >= price[i]) {
					int gain = price[i] - cost[j];
					if (gain >= 0) {
						sumGain += gain;
					}
				}
			}
			if (max < sumGain || max == sumGain && max_price > price[i]) {
				max = sumGain;
				max_price = price[i];
			}
		}

		return max_price;
	}