There was a guy named Rijul. He was a smart guy. Why wouldn't he be? After all he had encyclopedic memory. But sadly, he lost his bachpan to evil witch Aku. And now, he was unbearable.
Luckily he had a friend, Himanshu. According to legends, he knew the solution to Rijul's problem. He knew where the chest containing Rijul's bachpan is. He also had a scroll where he had list of locations all the N memories of Rijul. Each memory would give a bit about the key needed to unlock the chest. And he knew that to get the key, he would need to multiply the order in which he visited the locations with their actual position in the scroll and sum them all. i.e Lets say a memory was located at index y in scroll, but in his actual order of visiting, it occurred at index x, so key += x*y. But, co-ordinates were really complex and big. He somehow deciphered them to numbers, but how he achieved the goal is still a mystery.
Historians say that if we assume Himanshu was at point 0, and all the points were lying on positive x coordinate, he would have solved the problem if he covered them all in smallest time possible. Assuming he takes 1 unit of time to cover 1 unit of distance, you have to print the order in which he would have visited the co-ordinates so that it took him smallest time possible. Assume that as soon as he visits the last memory, chest containing bachpan would appear there itself. Also, print the value of the key needed to unlock the chest.
CONSTRAINTS:
1≤ T ≤ 100
1≤ N ≤ 104
1≤ A[i] ≤ 1030, where A[i] is location of ith memory.
NOTE: Everything is 1 indexed. Also, if A[i]=A[j], then he will visit the one which came earlier in the scroll, i.e he will visit A[i] first if i < j.
Total time taken : 100 units.
Key value = 1 * 3 + 2 * 4 + 3 * 2 + 4 * 1 = 21.