题解 | 预知
预知
https://www.nowcoder.com/practice/d9dd8fb2f4ca4385b3728b7bf9c9d0a4
t = int(input())#测试数据组数
for _ in range(t):
n = int(input())#当前组测试数据包含的卡牌种类,n种卡牌
cards = list(map(int,input().split()))#n种卡牌每种包含的卡牌数量
if n==1:#如果卡牌数量只有一种,那没有必胜策略,直接输出-1
print(-1)
else:#如果卡牌数量不只一种,想要必胜,那每种卡牌只留一张未知,或至少一种数量最多的卡牌全部已知(两种最差情况)
print(min(sum(cards)-n,max(cards)))


