Jack is worried about being single for his whole life, so he begins to use a famous dating app. In this app, the user is shown single men/women's photos one by one, and the user may choose between “yes” and “no”. Choosing “yes” means an invitation while choosing “no” means nothing. The photos would be shown one by one until the number of rest photos to be shown reaches zero. Of course, efficient and single Jack would always choose “yes”.
When viewing photos, Jack would have a “fake impression point” on every photo, which is not accurate. To calculate the “true impression point” of one photo, Jack would recall the “fake impression point” of every previous photo whose “fake impression point” is larger than this photo, and regard the smallest “fake impression point” of them as the “true impression point” of this photo. Jack would like to sum the “true impression point” of all photos as the outcome of his effort.
Note that if such a larger “fake impression point” does not exist, the “true impression point” of this photo is zero.
输入描述:
The first line contains an integer
(
) --- the number of photos.
The second line contains n integers
,
,
,
where
(
) is the “fake impression point” of the i-th photo.
输出描述:
Output a single integer --- the sum of the “true impression point” of all photos.