T=int(input()) N=int(input()) time=[int(input()) for i in range(N)] inf=1<<30 dp=[inf]*(1<