Shima has opened an art museum! Its best-known exhibit contains nanoblobs of various colors
arranged in a row. The gap between every pair of adjacent nanoblobs is exactly nanometers, or
meter.
One day, museum reviewer Jerry visits the exhibit. He begins by taking pictures under the following
rules:
If two nanoblobs appear in a picture, every nanoblob between them also appears in that picture.
No two pictures contain exactly the same collection of nanoblobs.
Jerry cannot take another picture without violating one of the previous two rules.
Jerry then scores every picture. If all nanoblobs in a picture have distinct colors, its score is
. Otherwise, he considers every pair of equally colored nanoblobs, finds the closest such pair,
and assigns the picture a score equal to their distance in meters.
Compute the sum of the scores of all Jerry's pictures.
输入格式
The first line contains an integer (), the number of nanoblobs.
The second line contains integers (), the colors of the
nanoblobs from left to right.