#C11458. Minimize Sum Differences by Removing One Element

    ID: 40776 Type: Default 1000ms 256MiB

Minimize Sum Differences by Removing One Element

Minimize Sum Differences by Removing One Element

Given an integer (m) (with (m \ge 2)), consider an array (b = [1, 2, \ldots, m]). You are allowed to remove exactly one integer from the array. After removal, the remaining array is re-indexed from 1 to (m-1). Your task is to choose the integer to remove such that the sum of absolute differences between each remaining element and its index is minimized. It can be shown that for every valid (m), removing the largest element (m) minimizes this sum. Write a program that, given (m), outputs the integer to be removed.

Example: If (m = 3), the array is [1, 2, 3]. Removing 3 gives the remaining array [1, 2] which minimizes the sum of absolute differences when compared with their indices.

inputFormat

The input consists of a single integer (m) provided via standard input, where (2 \le m \le 2 \times 10^5).

outputFormat

Output a single integer, which is the element that should be removed from the array to minimize the sum of absolute differences.## sample

2
2