

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
高橋くんは 種類の料理が食べ放題のビュッフェに行き、全種類の料理 (料理 , 料理 , , 料理 ) を 度ずつ食べました。
高橋くんが 番目に食べた料理は料理 でした。
高橋くんは、料理 を食べると満足度 を得ます。
また、料理 を食べた直後に料理 を食べると満足度 を追加で得ます。
高橋くんが得た満足度の合計を求めてください。
制約
- 入力は全て整数である。
- は全て異なる。
入力
入力は以下の形式で標準入力から与えられる。
出力
高橋くんが得た満足度の合計を整数で出力せよ。
入力例 1Copy
3 3 1 2 2 5 4 3 6
出力例 1Copy
14
以下のように高橋くんは合計 の満足度を得ました。
- 高橋くんはまず料理 を食べ、満足度 を得ました。
- 高橋くんは次に料理 を食べ、満足度 を得ました。
- 高橋くんは最後に料理 を食べ、満足度 を得ました。
入力例 2Copy
4 2 3 4 1 13 5 8 24 45 9 15
出力例 2Copy
74
入力例 3Copy
2 1 2 50 50 50
出力例 3Copy
150
Score : points
Problem Statement
Takahashi went to an all-you-can-eat buffet with kinds of dishes and ate all of them (Dish , Dish , , Dish ) once.
The -th dish he ate was Dish .
When he eats Dish , he gains satisfaction points.
Additionally, when he eats Dish just after eating Dish , he gains more satisfaction points.
Find the sum of the satisfaction points he gained.
Constraints
- All values in input are integers.
- are all different.
Input
Input is given from Standard Input in the following format:
Output
Print the sum of the satisfaction points Takahashi gained, as an integer.
Sample Input 1Copy
3 3 1 2 2 5 4 3 6
Sample Output 1Copy
14
Takahashi gained satisfaction points in total, as follows:
- First, he ate Dish and gained satisfaction points.
- Next, he ate Dish and gained satisfaction points.
- Lastly, he ate Dish and gained satisfaction points.
Sample Input 2Copy
4 2 3 4 1 13 5 8 24 45 9 15
Sample Output 2Copy
74
Sample Input 3Copy
2 1 2 50 50 50
Sample Output 3Copy
150