B - Nuts
Editorial
/


Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
本の木があり、 番目の木には 個の木の実が実っています。
シマリスは、次のルールで全ての木から木の実を収穫します。
- 実っている木の実が 個以下の木からは木の実を収穫しない
- 実っている木の実が 個より多い木からは、 個を残して残りの全てを収穫する
シマリスが収穫する木の実の個数の合計を求めてください。
制約
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例 1Copy
Copy
3 6 17 28
出力例 1Copy
Copy
25
本の木からそれぞれ 個の木の実を収穫します。よって合計は 個です。
入力例 2Copy
Copy
4 8 9 10 11
出力例 2Copy
Copy
1
Score : points
Problem Statement
There are trees. The -th tree bears nuts.
Chipmunk will harvest nuts from the trees in the following manner:
- From a tree with or fewer nuts, she does not take nuts.
- From a tree with more than nuts, she takes all but nuts.
Find the total number of nuts Chipmunk will take from the trees.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
Copy
3 6 17 28
Sample Output 1Copy
Copy
25
From the three trees, Chipmunk will take , , and nuts, for a total of nuts.
Sample Input 2Copy
Copy
4 8 9 10 11
Sample Output 2Copy
Copy
1