public static void getArr(int n, int m, int[] a) {
List<Integer> lists = new ArrayList<Integer>();
int flag = 0;
int k = 0;
int count = 0;
while(count < n) {
if(k == m) k = 0;
lists.add(a[k]);
for(int i = 0; i < lists.get(count) - 1; i++) {
lists.add(a[k]);
}
k++;
count++;
}
System.out.println(lists.size());
for (int j = 0; j < n; j++)
System.out.println(lists.get(j));
}