Get Back To Work
YOU: "I'm reading here that both you and Kevin were designated as the event organisers. Did you guys split the work evenly?"
RORY: "Ha! Are you kidding me? Kevin didn't really do anything. Spent most of the lead-up tinkering away on some AI thing he was pretty keen to show everyone."
YOU: "Did you do most of the managing on the day too?"
RORY: "I'd say so. Kevin was off having words with people here and there, from what I saw. I was just going around making sure everyone was alright and that we'd get there in the end."
YOU: "Where were you at around quarter to six?"
RORY: "Doing my rounds. Gleb and Lukaz were busy wrangling a speaker. I tried talking to Jamie, but he didn't even look at me. I ended up just talking to Parsa after that."
Rory is fed up. While every other committee member constantly stops working to chat, he's the one stuck doing everything. He has had enough.
Using the Town Hall's security cameras, he has spent the whole evening jotting down the exact minute he happened to spot each colleague taking a break. In his mad frenzy, he does not bother with names and notes these times in no particular order. With this information, he can prove that everyone's breaks have been suspiciously bunched together, and not spread apart like they should.
Rather than eyeballing his list, Rory has decided that the only rigorous way to make his case is to compare every single pair of sighting times he logged. He will add up the difference absolute time difference between each break and present the final number to ACPC management. A small total would mean everyone's break times are close together, proof of everyone's laziness. A large total means people's breaks were properly spread out.
But frankly, any number greater than 0 would be too big for Rory.
Input
The first line consists of one integer (
) which represents the number of break times Rory recorded.
The second line consists of integers
(
) which are the values of the break times Rory recorded.
Output
Output a single integer representing the sum of the gaps between each break time Rory recorded. In other words, output the sum of over every pair
.
Example
Input 1
3
1 2 10
Output 1
18
The time difference between timestamps are = 1,
= 9 and
= 8. This has a total of 18.
Input 2
4
4 11 2 7
Output 2
30
Comments