#C3214. Minimum Swaps to Sort: Restricted Swap Operations

    ID: 46617 Type: Default 1000ms 256MiB

Minimum Swaps to Sort: Restricted Swap Operations

Minimum Swaps to Sort: Restricted Swap Operations

In this problem, you are given an integer N which represents the size of an array containing elements from 0 to N-1. The array undergoes a special swap process, where every swap operation is final; that is, once two elements have been swapped, they must remain in their new positions and cannot be involved in further swaps.

Your task is to compute the minimum number of swaps required to sort the array under these constraints. It can be mathematically shown that the answer is given by the formula:

$N-1$

For example, if N is 4, the minimum number of swaps required is 3, and if N is 5, the answer is 4.

inputFormat

The first line contains an integer T representing the number of test cases. Each of the following T lines contains a single integer N (0 < N ≤ 109), representing the length of the array.

Input Format:

T
N1
N2
...
NT

outputFormat

For each test case, output a single line containing the minimum number of swaps required to sort the array. According to the problem's constraints, the answer is given by the expression $N-1$.

## sample
2
4
5
3

4

</p>