You are given N distinct positive integer. You are required to add at most 1 positive integer such that
- It is not equal to any given integer.
- It is less than the maximum value of the given integer.
- It is greater than the minimum value of the given integer.
- And after the addition of this integer, the sum of all N+1 elements is equal to K.
First, sum all the N elements and let it be S
- if S > K then it is not possible to achieve as we can add only positive integers.
- if S == K then answer is YES.
- if S < K then answer is YES if and only if
- K-S < maximum of N elements
- K-S > minimum of N elements
- K-S is not equal to any value from given N integer.