AlgoUniversity
  • Go Back
Discussion
GP Subsequences :

Author

Ayush Gangwani

Difficulty Level : Hard

Submissions : 868

Asked In : Sprinklr

Marks :20

: 7 | : 1

You are given an array $$$A$$$ containing $$$n$$$ integers. Your task is to determine the number of subsequences of length $$$\ge 2$$$ such that they form a Geometric Progression with a prime common ratio.

A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements. Two subsequences are considered different if they contain different indices of elements.

Input

The first line of input contains an integer $$$n$$$ $$$(1 \le n \le 10^4)$$$ — the number of elements in the array $$$A$$$.

The second line of input contains $$$n$$$ space separated integers $$$A_1, A_2, ... A_n$$$ $$$(1 \le A_i \le 10^5)$$$ — the elements of array $$$A$$$ respectively.

Output

Print a single integer — the number of subsequences of length $$$\ge 2$$$ such that they form a geometric progression with a prime common ratio. Since the number of subsequences can be rather large, print the answer modulo $$$10^9 + 7$$$.

Examples

Input
3
1 2 4
Output
3 
Input
5
2 3 4 6 18
Output
5 

Note

In sample test case 1, the GP subsequences are $$${[1,2], [2,4], [1,2,4]}$$$.

In sample test case 2, the GP subsequences are $$${[2,4], [2,6], [3,6], [6,18], [2,6,18]}$$$.

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.