#B3651. Array Adjustment Sum

    ID: 11310 Type: Default 1000ms 256MiB

Array Adjustment Sum

Array Adjustment Sum

Given an array of length \(n\) with elements \(a_1, a_2, \ldots, a_n\). To adjust the array, you are required to change the sign of the \(k\)-th element, i.e. replace \(a_k\) with \(-a_k\). After the modification, compute and output the sum of all elements in the adjusted array.

inputFormat

The input consists of two lines:

  • The first line contains two integers \(n\) and \(k\) (with \(1 \le k \le n \le 10^5\)).
  • The second line contains \(n\) space-separated integers \(a_1, a_2, \ldots, a_n\) (where \(|a_i| \le 10^9\)).

outputFormat

Output a single integer representing the sum of the array after changing the \(k\)-th element \(a_k\) to \(-a_k\).

sample

5 3
1 2 3 4 5
9