Problem

5/10

Insert by condition

Theory Click to read/hide

There are two options for adding an element to an ArrayList:
add(value);  - adding a value to the end of the ArrayList
add(index, value); - adding a value to the right place by index.

For example:

arr.add(10);
arr.add(5,10); 
 

Problem

Given an array of N positive elements greater than 1 (\(2<=N<=100\) ). Insert the value a before all elements that are multiples of a.


Input:
- at the input are given in the first line N - the number of array elements;
- the second line contains the number a;
- the third line contains N numbers - the values ​​of the array elements.

Output: output the resulting array to a string.
 
Examples
# Input Output
1
5
2
43  50  76  84 100 
43 2 50 2 76 2 84 2 100