import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList W = new ArrayList<>(); int L = sc.nextInt(); int N = sc.nextInt(); for(int i = 0; i < N; i++) { W.add(sc.nextInt()); } Collections.sort(W); int i = 0; while(L >= 0 && i < N) { L = L - W.get(i); System.out.println(L); if(L >= 0) { i++; } else { break; } } System.out.println(i); } }