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

~/algor $ cat problems/ochkoz-ishora-almashtirish

k sign flips

Easy 1000 ms 128 MB 24%
Share

$n$ integers are given. In one operation you may flip the sign of any one number (replace $x$ with $-x$); the same number may be chosen several times. What is the largest possible sum of the numbers after exactly $k$ operations?

Numbers in cells; the negative numbers whose sign was flipped and the new sum are highlighted

Input

The first line contains two positive integers: $n$ and $k$. The second line contains $n$ space-separated integers $a_{i}$.

Output

One integer — the largest sum.

Note

$1 \le n \le 10^{5}$
$1 \le k \le 10^{9}$
$-10^{9} \le a_{i} \le 10^{9}$

Examples

Input #1
5 3
-4 2 -1 3 -6
Output #1
16
Input #2
3 3
1 2 3
Output #2
4

Sign in to submit a solution

Signing up is free and takes a minute.