#include <stdio.h>
#include <stdlib.h>
int compar ( const void * a , const void * b ) {
return (*(int *)a) - (*(int *)b);
}
int main ( int argc ,char * argv[] ) {
int t;
scanf("%d" , &t);
while ( t-- ) {
int n;
scanf("%d" , &n);
int i = 0;
int * array = ( int *) malloc ( n * sizeof(int) );
for ( i = 0 ; i < n ; i++ ) {
scanf("%d" , &array[i]);
}
qsort(array , n , sizeof(int) , compar);
if ( array[n-1] < n ) {
printf("0\n");
continue;
}
long long int s = 1;
for ( i = 0 ; i < n ; i++ ) {
s = s * (array[i] - i);
s = s % 1000000007;
}
printf("%lld\n" , s);
}
printf("KILL BATMAN\n");
return 0;
}
System Design for Beginners
A masterclass that helps early engineers and product managers become great at designing scalable systems.
132+ learners
Details →System Design Masterclass
A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.
1000+ learners
Details →Redis Internals
Learn internals of Redis by re-implementing some of the core features in Golang.
98+ learners
Details →