Ties
At the opening of the «Tournament of Champions», N jury members are set to address the participants and guests. To symbolize their unity, all jury members will wear ties of the same color. These ties are stored in a chest located in a dark room, and each tie is available in one of M colors. You can enter the room only once, retrieve a certain number of ties from the chest, and bring them out. Your task is to determine the minimum number of ties you need to take out to ensure that there are at least N ties of the same color.
Input
The input consists of two lines. The first line contains two integers, N and M (1 ≤ N ≤ 10^6, 1 ≤ M ≤ 10^4). The second line contains M integers, each representing the number of ties available in each color. All these numbers are non-negative integers and do not exceed 10^9.
Output
The output should be a single integer — the minimum number of ties that need to be taken out of the chest. If it is impossible to guarantee at least N ties of the same color, output −1.