#C4483. One-Swap Sortability

    ID: 48026 Type: Default 1000ms 256MiB

One-Swap Sortability

One-Swap Sortability

You are given an array of n integers. Your task is to determine whether the array can be sorted in non-decreasing order (i.e., for all \( 1 \le i < n \), \( a_i \le a_{i+1} \)) using at most one swap between two of its elements.

If the array is already sorted or if it can be sorted by swapping exactly one pair of elements, then the answer is 1; otherwise, the answer is 0.

Note: A swap operation exchanges the positions of two elements.

Example:

Input: 5\n1 5 3 3 7\nOutput: 1

Input: 5\n1 3 5 3 4\nOutput: 0

</p>

inputFormat

The first line of input contains a single integer \( n \) representing the number of elements in the array. The second line contains \( n \) space-separated integers which are the elements of the array.

For example:

5
1 5 3 3 7

outputFormat

Output a single integer: 1 if the array can be sorted in non-decreasing order with at most one swap, otherwise 0.

## sample
5
1 5 3 3 7
1

</p>