跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F0651. On the Bench

  • ID: 657
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:挑战
  • 上传者:
  • 组合数学
  • 动态规划
  • 数学
  • 挑战
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

On the Bench

题目描述

C. On the Bench
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A year ago on the bench in public park Leha found an array of n numbers. Leha believes that permutation p is right if for all 1≤i<n condition, that api·api+1 is not perfect square, holds. Leha wants to find number of right permutations modulo 109+7.

Input

First line of input data contains single integer n (1≤n≤300) − length of the array.

Next line contains n integers a1,a2,... ,an (1≤ai≤109) − found array.

Output

Output single integer − number of right permutations modulo 109+7.

Examples
Input
3
1 2 4
Output
2
Input
7
5 2 4 2 4 1 1
Output
144
Note

For first example:

[1,2,4] − right permutation, because 2 and 8 are not perfect squares.

[1,4,2] − wrong permutation, because 4 is square of 2.

[2,1,4] − wrong permutation, because 4 is square of 2.

[2,4,1] − wrong permutation, because 4 is square of 2.

[4,1,2] − wrong permutation, because 4 is square of 2.

[4,2,1] − right permutation, because 8 and 2 are not perfect squares.


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 63 题。保留原作者与原赛事署名。