import java.util.*;
class GFG{
static int power(int a, int b)
{
int result = 1;
while (b > 0) {
if (b % 2 == 1) {
result = result * a;
}
a = a * a;
b = b / 2;
}
return result;
}
static int factorial(int n)
{
int fact = 1;
for (int i = 1; i <= n; i++) {
fact = fact * i;
}
return fact;
}
static void findNoOfArrays(int[] a, int n)
{
int sum = 0, s1, c = 0;
HashMap<Integer,Integer> mp = new HashMap<Integer,Integer>();
for (int i = 0; i < 2 * n; i++) {
if(mp.get(a[i])==null)
mp.put(a[i], 1);
else
mp.put(a[i], mp.get(a[i]) + 1);
sum = sum + a[i];
}
boolean isArrayPossible = true;
int ans = factorial(n - 1);
s1 = sum / (n + 1);
if (mp.get(s1) >= 2) {
mp.replace(s1, mp.get(s1) - 2);
}
else {
isArrayPossible = false;
}
if (isArrayPossible) {
for (Map.Entry<Integer,Integer> m:mp.entrySet()) {
if (m.getKey() == s1-m.getKey()) {
if (mp.get(m.getKey()) % 2 != 0) {
isArrayPossible = false;
break;
}
}
if (m.getKey() != s1 - m.getKey()) {
if (mp.get(m.getKey())
!= mp.get(s1 - m.getKey())) {
isArrayPossible = false;
break;
}
}
if (m.getValue() > 0) {
if (m.getKey() != s1 - m.getKey()) {
c = c + m.getValue();
ans = ans * power(2, m.getValue());
ans = ans / factorial(m.getValue());
mp.replace(m.getKey(),0);
mp.replace(s1 - m.getKey(),0);
}
if (m.getKey() == s1 - m.getKey()) {
c = c + m.getValue() / 2;
ans = ans / factorial(m.getValue() / 2);
mp.replace(m.getKey(),0);
}
}
}
}
if (c < n - 1 && isArrayPossible == false) {
System.out.println("0");
}
else {
System.out.println(ans);
}
}
public static void main(String args[])
{
int[] arr1 = { 5, 2, 3, 5 };
int n1 = arr1.length;
findNoOfArrays(arr1, n1 / 2);
int []arr2 = { -1, -1, -1, 0, 1, 0,
1, 0, 1, 0, 0, 0 };
int n2 = arr2.length;
findNoOfArrays(arr2, n2 / 2);
}
}