Scallion Chicken

Find the largest integer piece length x such that the scallions yield at least C pieces, then print the total leftover length.

Medium5Binary searchGreedyArrayMathInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

Seunggyun likes to cook, so he opened a chicken shop. The main dish is scallion chicken. Before opening, he stopped by the market and bought several scallions of uneven lengths.

To keep the taste the same across servings, Seunggyun puts a scallion piece of the same length into every serving. He believes more scallion tastes better, so he makes that length as large as he can. One serving takes exactly one piece, so pieces from different scallions are never combined into one serving.

The ruler in the shop has integer marks only, so a scallion is cut at integer lengths. A scallion of length LL yields at most L/x\lfloor L / x \rfloor pieces of length xx, and the remaining LmodxL \bmod x cannot be used as a piece.

Choose the largest integer length xx that still allows all CC ordered servings to be made, and print how much scallion is left over. The leftover is the total length of all scallions minus the C×xC \times x that went into the servings. Seunggyun puts that leftover into his ramen at the end of the day.

Input

The first line contains the number of scallions SS and the number of ordered servings CC, separated by a space. (1S1061 \le S \le 10^6, 1C1061 \le C \le 10^6, SCS \le C)

Each of the next SS lines contains the length LL of one scallion as an integer. (1L1091 \le L \le 10^9)

The total length of the scallions is at least CC, so all ordered servings can always be made.

Output

Print on one line the total length of scallion that Seunggyun puts into his ramen.

Hint

With scallions of length 440440, 350350, 230230 and 55 ordered servings, the largest length per serving is 175175. Two pieces come from 440440, two from 350350, and one from 230230, which makes all 55 servings, and 90+0+55=14590 + 0 + 55 = 145 is left over.