Vergil is a master swordsman with a secret technique: "Judgement Cut End". When performing this technique, Vergil cuts up a group of enemies stylishly; however, he wants to achieve the maximum value of style.
In every battle, all his enemies would form a row to attack him and each enemy has a different enemy type. Vergil must slice them all down until none are left. He can choose to cut down any number of enemies with a single slice as long as they are of the same type and adjacent to one another. For every enemy Vergil cuts down with a single slice, Vergil gets k * k style points (with k being the number of enemies).
Help Vergil calculate his style points.
First line contains the number of enemies there are (1 <= N <= 100)
N number of integers representing the enemy types in the row (1 <= Enemyi <= 100)
The maximum stylish points Vergil can get followed by a newline.