Logo
(追記) (追記ここまで)

20627번 - Non-Trivial Common Divisor 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB51413782.222%

문제

You are given a positive integer sequence $A$ of length $N$. You can remove any numbers from the sequence to make the sequence "friendly". A sequence is called friendly if there exists an integer $k$ ($k>1$) such that every number in the sequence is a multiple of $k$. Since the empty sequence is friendly, it is guaranteed that you can make the initial sequence friendly.

You noticed that there may be multiple ways to make the sequence friendly. So you decide to maximize the sum of all the numbers in the friendly sequence. Please calculate the maximum sum of the all numbers in the friendly sequence which can be obtained from the initial sequence.

입력

The input consists of a single test case formatted as follows: the first line consists of a single integer $N$ (1ドル \le N \le 1000$). The $i+1$-st line consists of an integer $A_i$ (1ドル \le A_i \le 10^9$) for $(1 \le i \le N)$.

출력

Print the maximum sum of all the numbers in the friendly sequence which can be obtained from the initial sequence.

제한

예제 입력 1

6
1
2
3
4
5
6

예제 출력 1

12

예제 입력 2

3
173
1733
111733

예제 출력 2

111733

예제 입력 3

4
1
1
1
1

예제 출력 3

0

예제 입력 4

10
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999

예제 출력 4

9999999990

예제 입력 5

1
999999999

예제 출력 5

999999999

예제 입력 6

10
28851
8842
9535
2311
25337
26467
12720
10561
8892
6435

예제 출력 6

56898

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2020 > Day 5: JAG Summer+ Opening Contest B번

Contest > ICPC Japanese Alumni Group > JAG Summer Camp > JAG Summer Camp 2019 Day 1 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /