Cowlendar

시간 제한2초메모리 제한1024 MB

요약
각 달이 적어도 4주이고 달 길이 N개의 L에 대한 나머지가 많아야 3가지인 양의 정수 L을 모두 찾아 합을 구한다.
난이도

어려움10점 중 8점

유형
정수론, 수학, 정렬, 구현
정답자
아직 제출이 없습니다

문제

Bessie has woken up on a strange planet. In this planet, there are NN (1≤N≤1041\le N\le 10^4) months, with a_1,…,a_Na\_1, \ldots, a\_N days, respectively (1≤a_i≤4⋅1091\leq a\_i \leq 4 \cdot 10^9, all a_ia\_i are integers). In addition, on the planet, there are also weeks, where each week is LL days, with LL being a positive integer. Interestingly, Bessie knows the following:

  • For the correct LL, each month is at least 44 weeks long.
  • For the correct LL, there are at most 33 distinct values of a_i mod La\_i\bmod L.

Unfortunately, Bessie has forgotten what LL is! Help her by printing the sum of all possible values of LL.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

입력

The first line contains a single integer NN. The second line contains NN space-separated integers, a_1,…,a_Na\_1, \ldots, a\_N.

출력

A single integer, the sum of all possible values of LL.

예제2

  1. 예제 1

    입력
    12
    31 28 31 30 31 30 31 31 30 31 30 31
    
    예상 출력
    28
    
  2. 예제 2

    입력
    4
    31 35 28 29
    
    예상 출력
    23