Problem:
Score : 2000 points

Problem Statement

Snuke received an integer sequence a of length 2N-1.

He arbitrarily permuted the elements in a, then used it to construct a new integer sequence b of length N, as follows:

b_1 = the median of (a_1)

b_2 = the median of (a_1, a_2, a_3)

b_3 = the median of (a_1, a_2, a_3, a_4, a_5)

:

b_N = the median of (a_1, a_2, a_3, ..., a_{2N-1})

How many different sequences can be obtained as b? Find the count modulo 10^{9} + 7.

Constraints

1 ≤ N ≤ 50

1 ≤ a_i ≤ 2N-1

a_i are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_{2N-1}

Output

Print the answer.

Sample Input 1

2
1 3 2

Sample Output 1

3

There are three sequences that can be obtained as b: (1,2), (2,2) and (3,2). Each of these can be constructed from (1,2,3), (2,1,3) and (3,1,2), respectively.

Sample Input 2

4
1 3 2 3 2 4 3

Sample Output 2

16

Sample Input 3

15
1 5 9 11 1 19 17 18 20 1 14 3 3 8 19 15 16 29 10 2 4 13 6 12 7 15 16 1 1

Sample Output 3

911828634

Print the count modulo 10^{9} + 7.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;
const int md=1e9+7;
int a[110];
int dp[110][110][110];
void Add(int &x,int y){
	x=(x+y)%md;
}
int main(){
//	freopen("F.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<2*n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n*2);
	dp[n][1][1]=1;
	int vl,vr;
	for(int i=n;i>1;i--){
		vl=a[n*2-i]!=a[n*2-i+1];
		vr=a[i]!=a[i-1];
		for(int l=1;l<n*2;l++)
			for(int r=1;r<n*2;r++){
				Add(dp[i-1][l+vl][r+vr],dp[i][l][r]);
				for(int j=1;j<l+vl;j++)
					Add(dp[i-1][j][r+vr+1],dp[i][l][r]);
				for(int j=1;j<r+vr;j++)
					Add(dp[i-1][l+vl+1][j],dp[i][l][r]);
			}
	}
	int ans=0;
	for(int l=1;l<n*2;l++)
		for(int r=1;r<n*2;r++)
			Add(ans,dp[1][l][r]);
	printf("%d\n",ans);
	return 0;
}