시간 제한메모리 제한제출정답맞힌 사람정답 비율
2.5 초 1024 MB33101043.478%

문제

Domagoj is in the big city of London! Right now, there is a sequence of tall skyscrapers in front of him and he wants to take a photograph to remember the moment.

The sequence of skyscrapers can be represented as a sequence of n numbers h1, h2, . . . , hn where the number hi represents the height of the i-th skyscraper. Domagoj will photograph a contiguous subsequence of skyscrapers. To capture more of the city’s beauty, he wants to photograph at least k skyscrapers.

Domagoj has a strange sense of beauty of a photograph. He is very happy when there are tall skyscrapers in the photograph, but he is even happier when their heights have a large common divisor! If we label the heights of the contiguous skyscrapers on the photograph with hl, . . . , hr, and with g the greatest common divisor of the selected heights, then Domagoj defines the beauty of the photograph as g · (hl + . . . + hr).

Help Domagoj determine the beauty of the most beautiful photograph with at least k skyscrapers!

입력

The first line contains two integers n, k (1 ≤ k ≤ n ≤ 106), the number of skyscrapers, and the number k.

The second line contains n integers h1, h2, . . . , hn (1 ≤ hi ≤ 106), the heights of the skyscrapers, in order.

출력

Print a single line with the required number from the task.

서브태스크

번호배점제한
111

n, k ≤ 100

222

n, k ≤ 5000

327

hi ≤ 100

418

n, k ≤ 5 · 104

532

No additional constraints.

예제 입력 1

6 2
2 1 4 4 4 2

예제 출력 1

48

예제 입력 2

4 1
7 3 9 4

예제 출력 2

81

힌트

Clarification of the first example: Domagoj photographed skyscrapers ( 4, 4, 4 ), so the total beauty is 4 · (4 + 4 + 4) = 48

Clarification of the second example: Domagoj photographed only the skyscraper ( 9 ), so the total beauty is 9 · 9 = 81.

채점 및 기타 정보

  • 예제는 채점하지 않는다.