# A. Cubes Sorting SOLUTION Codeforces

Page Contents

## Cubes Sorting SOLUTION Codeforces Round #672 (Div. 2)

Wheatley chose to attempt to make a test chamber. He made a pleasant test chamber, yet there was just one detail missing — solid shapes.

For finishing the chamber Wheatley needs n solid shapes. I-th 3D square has a volume ai.

Wheatley needs to put solid shapes so that they would be arranged in a non-diminishing request by their volume. Officially, for each i>1, ai−1≤ai must hold.

To accomplish his objective, Wheatley can trade two neighboring shapes. It implies that for any i>1 you can trade 3D squares on positions i−1 and I.

Be that as it may, there is an issue: Wheatley is fretful. On the off chance that Wheatley needs more than n⋅(n−1)2−1 trade activities, he won’t accomplish this exhausting work.

Wheatly needs to know: can blocks be arranged under this conditions?

Info

Each test contains different experiments.

The main line contains one sure number t (1≤t≤1000), indicating the quantity of experiments. Portrayal of the experiments follows.

The principal line of each experiment contains one sure whole number n (2≤n≤5⋅104) — number of blocks.

The subsequent line contains n positive numbers ai (1≤ai≤109) — volumes of 3D shapes.

It is ensured that the entirety of n over all experiments doesn’t surpass 105.

Yield

For each experiment, print a word in a solitary line: “YES” (without quotes) if the 3D squares can be arranged and “NO” (without quotes) in any case.

Model

inputCopy

5 3 2 1 4

2 1

outputCopy

Indeed

Indeed

NO

Note

In the primary experiment it is conceivable to sort all the shapes in 7 trades.

In the subsequent experiment the 3D shapes are as of now arranged.

In the third experiment we can make 0 trades, however the blocks are not arranged at this point, so the appropriate response is “NO”.