数组调整
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();int k = scanner.nextInt();int[] arr = new int[n];for (int i = 0; i < n; i++) {arr[i] = scanner.nextInt();}int sum = findAdjustedArraySum(arr, n, k);System.out.println(sum);}private static int findAdjustedArraySum(int[] arr, int n, int k) {int sum = 0;for (int i = 0; i < n; i++) {if (i == k - 1) {arr[i] = -arr[i];}sum += arr[i];}return sum;}
}