Cộng Dư

View as PDF

Submit solution

Points: 0.60
Time limit: 2.0s
Memory limit: 1G

Authors:
Problem type
Problem Statement

Bạn được cho N số nguyên dương ~a_1, a_2, ..., a_N~ .

Đối với số nguyên không âm ~m~ , cho ~f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N)~ .

Ở đây, ~X\ mod \ Y~ biểu thị phần còn lại của phép chia ~X~ cho ~Y~ .

Tìm giá trị tối đa của ~f~ .

Constraints
  • Tất cả các giá trị đầu vào là số nguyên
  • ~2 \leq N \leq 3000~
  • ~2 \leq a_i \leq 10^5~

Input

Đầu vào định dạng theo tiêu chuẩn sau:

~N~

~a_1~ ~a_2~ ~...~ ~a_N~

Output

In ra giá trị tối đa của ~f~ .


Sample Input 1
3
3 4 6
Sample Output 1
10

~f(11) = (11\ mod\ 3) + (11\ mod\ 4) + (11\ mod\ 6) = 10~ là giá trị tối đa của ~f~ .


Sample Input 2
5
7 46 11 20 11
Sample Output 2
90

Sample Input 3
7
994 518 941 851 647 2 581
Sample Output 3
4527

Comments

Please read the guidelines before commenting.


There are no comments at the moment.