Cowlendar
Time limit2sMemory limit1024 MB
Given month lengths a_i, find the sum of all week lengths L where every month is at least 4 weeks and a_i mod L takes at most 3 values.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Hash map
- Solved
- No attempts yet
Problem
Bessie has woken up on a strange planet. This planet has () months, with days, respectively (, all are integers). The planet also has weeks. Each week is days, where is a positive integer.
Bessie knows the following about the correct :
- Each month is at least weeks long.
- There are at most distinct values of .
Bessie has forgotten what is. Print the sum of all possible values of .
The large integers in this problem may require 64-bit integer types (for example, "long long" in C/C++).
Input
The first line contains a single integer . The second line contains space-separated integers .
Output
Print a single integer, the sum of all possible values of .