Preparing NOJ

# Sled Tracks

1000ms 262144K

## Description:

Santa needs to deliver gifts to all the inhabitants of Speedway! Unfortunately, as it doesn't snow on Speedway (mostly), his sleigh will damage the nice brickwork!

As we all know, Speedway is built in a line, conveniently segmented into $N$ locations. Although speedy, Santa's delivery system hasn't been fully optimized, so he travels back-and-forth to deliver these gifts.

Beginning at the first provided location, Santa will travel between all $N$ of these locations. When Santa travels between a location $A$ and $B$, he creates one unit of damage at each location between $A$ and $B$ (including $A$, not including $B$).

To help the UT Maintenance team, please determine how much total damage is caused by Santa's sleigh.

## Input:

The first line of input contains a single integer $N$, where $2 \leq N \leq 1000$.

Then $N$ more lines follow, each containing a single integer, representing all the buildings in the order in which he visits them.

## Output:

A single integer, the total damage that Santa's sleigh creates on Speedway.

## Sample Input:

2
2
1


## Sample Output:

1


## Sample Input:

3
3
1
2


## Sample Output:

3


Info

Provider CodeForces Gym

Code GYM103380C

Tags

Submitted 0

Passed 0

AC Rate 0%

Date 10/31/2021 14:46:37

Related

Nothing Yet