Forming a regular polygon

2.6

19 votes
Basic Math, Algorithms, Math
Problem

You are given N line segments. Print the number of subsets of these lines that form a regular polygon. A polygon is regular if and only if all of the edges of it are of equal length.

Input format

  • The first line contains N
  • The second line contains N numbers denoting the length of the line segments.

Output format

Print the answer modulo 109+7.

Constraints
1N1061Ai108

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

[3, 3, 3]

[4, 4, 4] (4 ways)

[4, 4, 4, 4]

 

Editor Image

?