|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||10||9||8||88.889%|
Ms. Hall wants to teach her class about common factors. She arranges her students in a circle and assigns each student an integer in the range 2..109 inclusive. She also provides the students with crepe paper streamers. The students are to stretch these streamers between pairs of students, and pull them tight. But, there are some rules.
Suppose Ms. Hall has four students, and she gives them the numbers 2, 3, 30 and 45. In this arrangement, there is one way to stretch the streamers:
In this arrangement, there are three ways to stretch the streamers:
In how many ways can the students hold the streamers subject to Ms. Hall’s rules? Two ways are different if and only if there is a streamer between two given students one way, but none between those two students the other way.
Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input will contain a single integer n (2 ≤ n ≤ 300), which is the number of Ms. Hall’s students.
Each of the next n lines will hold an integer x (2 ≤ x ≤ 109). These are the numbers held by the students, in order. Remember, the students are standing in a circle, so the last student is adjacent to the first student.
Output a single integer, which is the number of ways Ms. Hall’s students can satisfy her rules. Since this number may be very large, output it modulo 109 + 7.
4 30 3 2 45
4 3 30 2 45