k=int(input()) p=int(input()) br=0 while k>0 and p>0: kol=int(input()) if kol<=k: k=k-kol p=p-1 br=br+1 else: break print(k,p,br)