#t308. 邮票问题(stamp)

邮票问题(stamp)

Stamps Problem

Problem Background

Special for beginners, ^_^

Problem Description

There are mm kinds of stamps with known denominations, and nn stamps of each kind. Using no more than nn stamps in total, from denomination 1 onward, what is the largest contiguous range of denominations you can form? (1≤m≤1001 \le m \le 100, 1≤n≤1001 \le n \le 100, 1≤1 \le stamp denomination ≤255\le 255).

Input Format

The first line: the values of m,nm,n, separated by a single space.

The second line: A[1…m]A[1\dots m] (the denominations), separated by single spaces.

Output Format

The maximum value of the contiguous range of denominations.

Sample Input

3 4
1 2 4

Sample Output

14

Constraints

1s, 1024KiB for each test case.