#t422. 糖果
糖果
Candies
Problem Description
Because of his great contribution to keeping the world at peace, Dzx was given an unlimited free coupon from the candy company, valid on May 23, 2010. On that day Dzx may choose any subset of the company's products and take them home. The products each contain a certain number of candies. Dzx wants the total number of candies in the chosen products to be a multiple of , so that he can share the candies equally with the partners who helped him keep the peace. Subject to this condition, the larger the total, the better. What is the maximum number of candies Dzx can take home?
Note: Dzx can only take a whole product — he cannot split a product.
Input Format
The first line contains two integers () and ().
The next lines each contain one integer: the number of candies in that product, not exceeding .
Output Format
The maximum total number of candies satisfying the requirement. If no subset has a total that is a multiple of , output .
Sample Input
5 7
1
2
3
4
5
Sample Output
14
Hint
Dzx's choice is , so the total is a multiple of , and it is the choice with the largest possible total.
Limitation
1 s, 1024 KiB for each test case.