AtCoder Beginner Contest 103
C
Modulo Summation
AtCoder
⌀ 451
原题
← BD →
翻译中…

Problem Statement

翻译中…

You are given $N$ positive integers $a_1, a_2, ..., a_N$.

翻译中…

For a non-negative integer $m$, let $f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N)$.

翻译中…

Here, $X\ mod\ Y$ denotes the remainder of the division of $X$ by $Y$.

翻译中…

Find the maximum value of $f$.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $2 \leq N \leq 3000$
  • $2 \leq a_i \leq 10^5$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
a_1 a_2 ... a_N

翻译中…

Output

翻译中…

Print the maximum value of $f$.

翻译中…

样例

Input #1
3
3 4 6
Output #1
10
$f(11) = (11\ mod\ 3) + (11\ mod\ 4) + (11\ mod\ 6) = 10$ is the maximum value of $f$.
Input #2
5
7 46 11 20 11
Output #2
90
Input #3
7
994 518 941 851 647 2 581
Output #3
4527
题目信息
题号
abc103_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。