Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/massiv-k-ta-ongga-surish

Shift the array right by k

Medium 1000 ms 64 MB 49%
Share

An array of $n$ elements and an integer $k$ are given. Cyclically shift the array to the right $k$ times: at each shift the last element moves to the beginning and the rest move one position to the right. Print the resulting array. $k$ may be very large.

The array around a circle: elements move k steps to the right, the last ones move to the beginning

Input

The first line contains two integers: $n$ and $k$.
The second line contains $n$ integers — the elements of the array.

Output

$n$ integers separated by spaces.

Note

$1 \le n \le 1000$
$0 \le k \le 10^{9}$
the elements are from $-10^{6}$ to $10^{6}$

Examples

Input #1
5 2
1 2 3 4 5
Output #1
4 5 1 2 3
Input #2
3 7
10 20 30
Output #2
30 10 20

Sign in to submit a solution

Signing up is free and takes a minute.