import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
in.nextLine();
ArrayList<Integer> list = new ArrayList<>();
String[] str = in.nextLine().split(" ");
int count = 0;
int whole = 0;
int k = 0;
while (whole <= n) {
k %= m;
int t = Integer.valueOf(str[k]);
list.add(Integer.valueOf(str[k]));
k++;
for (int j = 0; j < list.get(count) - 1; j++) {
whole++;
list.add(t);
}
count++;
}
for (int s = 0; s < n; s++)
System.out.println(list.get(s));
in.close();
}
}