import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); int[] weights = new int[n]; int[] quantities = new int[n]; for (int i = 0; i < n; i++) { weights[i] = scanner.nextInt()...