Problem:
Score : 200 points

Problem Statement

Rng is preparing a problem set for a qualification round of CODEFESTIVAL.

He has N candidates of problems. The difficulty of the i-th candidate is D_i.

There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.

Determine whether Rng can complete the problem set without creating new candidates of problems.

Constraints

1 \leq N \leq 200,000

1 \leq D_i \leq 10^9

1 \leq M \leq 200,000

1 \leq T_i \leq 10^9

All numbers in the input are integers.

Partial Score

100 points will be awarded for passing the test set satisfying N \leq 100 and M \leq 100.

Input

Input is given from Standard Input in the following format:

N
D_1 D_2 ... D_N
M
T_1 T_2 ... T_M

Output

Print YES if Rng can complete the problem set without creating new candidates of problems; print NO if he cannot.

Sample Input 1

5
3 1 4 1 5
3
5 4 3

Sample Output 1

YES

Sample Input 2

7
100 200 500 700 1200 1600 2000
6
100 200 500 700 1600 1600

Sample Output 2

NO

Not enough 1600s.

Sample Input 3

1
800
5
100 100 100 100 100

Sample Output 3

NO

Sample Input 4

15
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
9
5 4 3 2 1 2 3 4 5

Sample Output 4

YES

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

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
     
    #define BIG 2000000007
     
    #define MOD 1000000007
    typedef unsigned long long ull;
    typedef   signed long long sll;
     
    #define N_MAX 200000
    #define M_MAX 200000
     
    typedef struct {
    	int a;
    	int b;
    } hw;
     
     
    const hw vector8[8] = {
    	{-1, -1},
    	{-1,  0},
    	{-1, +1},
    	{ 0, -1},
    	{ 0, +1},
    	{+1, -1},
    	{+1,  0},
    	{+1, +1}
    };
     
    ull n, m;
    ull h, w;
    ull k;
    ull va, vb, vc, vd, ve, vf;
    int a[N_MAX];
    // sll a[N_MAX];
    int b[M_MAX];
    // ull dp[N_MAX][M_MAX + 1];
    // char s[N_MAX + 1];
    // char t[N_MAX + 1];
    // char s[N_MAX][M_MAX + 1];
    // hw arr[N_MAX];
    // hw brr[M_MAX];
    // ull digitdp[102][   2][    2];
    //          pos  less  carry
     
    void swap_adj(ull *a, ull *b){
    	ull tmp = *b;
    	*b = *a;
    	*a = tmp;
    	return;
    }
     
    ull divide(ull a, ull b){
    	ull x = MOD - 2;
    	ull ans = 1;
    	while (x) {
    		if (x & 1) ans = (ans * b) % MOD;
    		b = (b * b) % MOD;
    		x /= 2;
    	}
    	return (a * ans) % MOD;
    }
     
    int digits(ull x){
    	int i = 1;
    	while (x >= 10) {
    		x /= 10;
    		i++;
    	}
    	return i;
    }
     
    int min(ull x, ull y){
    	return (x < y) ? x : y;
    }
     
    ull gcd(ull x, ull y){
    	if (x < y) {
    		return gcd(y, x);
    	} else if (y == 0) {
    		return x;
    	} else {
    		return gcd(y, x % y);
    	}
    }
     
    ull bitpow(ull a, ull x){
    	ull result = 1;
    	while (x) {
    		if (x & 1) {
    			result *= a;
    			result %= MOD;
    		}
    		x /= 2;
    		a = (a * a) % MOD;
    	}
    	return result;
    }
     
    // int nextroute(int arr[]){
    // 	int i = n - 1;
    // 	int j, x;
    // 	while (arr[i - 1] > arr[i]) i--;
     
    // 	x = n;
    // 	for (j = i; j < n; j++) {
    // 		if (arr[j] < arr[i - 1]) continue;
    // 		if (x == n || arr[x] > arr[j]) x = j;
    // 	}
    // 	arr[i - 1] ^= arr[x];
    // 	arr[x] ^= arr[i - 1];
    // 	arr[i - 1] ^= arr[x];
     
    // 	qsort(&arr[i], n - i, sizeof(int), comp);
    // 	return 0;
    // }
     
    int nibutan_target(ull target){
    	ull maxdist = (target * (target + 1) / 2); // 時刻targetまでに到着できる距離は[-maxdist, maxdist]
    	return (n <= maxdist);
    }
     
    int targetdig(ull x, int index /* 1-indexed */){
    	// static...?
    	int posmax = digits(x);
    	if (posmax < index) return -1;
    	while (posmax > index) {
    		posmax--;
    		x /= 10;
    	}
    	return x % 10;
    }
     
    int intcomp(const void *left, const void *right){
    	if ((*(int*)left) < (*(int*)right)) {
    		return -1;
    	} else if ((*(int*)left) > (*(int*)right)) {
    		return +1;
    	} else {
    		return 0;
    	}
    }
     
    int ullcomp(const void *left, const void *right){
    	if ((*(ull*)left) < (*(ull*)right)) {
    		return -1;
    	} else if ((*(ull*)left) > (*(ull*)right)) {
    		return +1;
    	} else {
    		return 0;
    	}
    }
     
    int hwAcomp(const void *left, const void *right){
    	return intcomp(&(((hw*)left)->a), &(((hw*)right)->a));
    }
     
    int hwBcomp(const void *left, const void *right){
    	return intcomp(&(((hw*)left)->b), &(((hw*)right)->b));
    }
     
    int hwABcomp(const void *left, const void *right){
    	int x = hwAcomp(left, right);
    	if (x) return x;
    	return hwBcomp(left, right);
    }
     
    ull solve(){
    	int i, j;
     
    	int kinds[N_MAX];
    	int kindnum[N_MAX] = {0};
    	int kindmax = 0;
     
    	qsort(a, n, sizeof(int), intcomp);
     
    	for (i = 0; i < n; i++) {
    		if (i == 0 || a[i - 1] != a[i]) {
    			kinds[kindmax] = a[i];
    			kindmax++;
    		}
     
    		kindnum[kindmax - 1]++;
    	}
     
    	// puts("!");
     
    	for (i = 0; i < m; i++) {
    		int ok = 0;
    		int ng = kindmax;
    		while (ok + 1 < ng) {
    			int med = (ok + ng) / 2;
    			if (kinds[med] <= b[i]) {
    				ok = med;
    			} else {
    				ng = med;
    			}
    		}
    		if (kinds[ok] != b[i] || kindnum[ok] <= 0) {
    			puts("NO");
    			return 1;
    		}
    		kindnum[ok]--;
    	}
     
    	puts("YES");
    	return 0;
    }
     
    int main(void){
    	int i, j;
     
    	scanf("%llu", &n);
    	for (i = 0; i < n; i++) {
    		scanf("%d", &a[i]);
    	}
    	scanf("%llu", &m);
    	for (i = 0; i < m; i++) {
    		scanf("%d", &b[i]);
    	}
     
    	solve();
     
    	return 0;
    }