L=int(input()) N=int(input()) W=sorted(map(int,input().split())) total=0 cnt=0 for i in W: total+=i if L