When John and Brus were high school students, they liked to investigate integer sequences.
Once, John wrote down a sequence containing only positive integers.
Brus wanted to change the sequence so it contained only "lucky" numbers.
Brus considered a number lucky only if it was evenly divisible by 4 or 7 (or both).
(Note that 0 is a lucky number by this definition.)
For each number x in John's sequence, Brus did the following.
If x was lucky, he did not change it.
Otherwise, he replaced x with a lucky number y (not necessarily positive) such that the absolute value of the difference between x and y was minimal.
If there were two such values for y, he chose the smaller one.
You are given an int[] sequence containing John's original sequence.
Return the sequence after Brus made all his changes.
|