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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	int N=sc.nextInt();

    	MapUtilStringInt D=new MapUtilStringInt();

    	D.receiveKeys(N, sc);

    	int M=sc.nextInt();

    	for(int i=0;i<M;i++) {
    		String t=sc.next();

    		D.addValue(t, -1);
    	}

    	for(Integer I:D.getValuesAscKey()) {
    		if(I<0) {
    			System.out.println("NO");
    			return;
    		}
    	}

    	System.out.println("YES");


    }

}

class MapUtilStringInt {

	private Map<String,Integer> data;


	public MapUtilStringInt() {

		data=new HashMap<String,Integer>();

	}


	public void receiveDataSet(int n,Scanner sc) {

		for(int i=0;i<n;i++) {
			String bufK=sc.next();
			Integer bufV=sc.nextInt();

			putWithCheckAndAdd(bufK,bufV);
		}

	}

	public void addValue(String key,int val) {

		if(data.containsKey(key)) {
			data.put(key, data.get(key)+val);
		}else {
			data.put(key, val);
		}

	}

	public void putWithCheckAndAdd(String key,Integer Value) {


		if(data.containsKey(key)) {
			data.put(key, data.get(key)+Value);
		}else {
			data.put(key, 1);
		}

	}


	public void receiveKeys(String s) {

		String[] buf=s.split("");

		for(int i=0;i<buf.length;i++) {

			putWithCheckAndIncrement(buf[i]);
		}

	}

	public void receiveKeys(int n,Scanner sc) {

		for(int i=0;i<n;i++) {
			String bufK=sc.next();

			putWithCheckAndIncrement(bufK);
		}

	}



	public void putWithCheckAndIncrement(String key) {


		if(data.containsKey(key)) {
			data.put(key, data.get(key)+1);
		}else {
			data.put(key, 1);
		}

	}

	public Integer getValue(String key) {
		return data.get(key);
	}

	public List<Integer> getValuesAscKey() {

		List<Integer> result=new ArrayList<Integer>();
		// キーでソートする
        Object[] mapkey = data.keySet().toArray();
        Arrays.sort(mapkey);

        for (Object nKey : mapkey)
        {
            result.add(data.get(nKey));
        }

        return result;
	}

	public List<Integer> getValuesDscKey() {

		List<Integer> result=new ArrayList<Integer>();
		// キーでソートする
        Object[] mapkey = data.keySet().toArray();
        Arrays.sort(mapkey, Collections.reverseOrder());

        for (Object nKey : mapkey)
        {
            result.add(data.get(nKey));
        }

        return result;
	}

	public Integer getBestN(int n) {

		int result=-1;

		int index=n-1;

		if(index>=0 && index<=data.size()-1) {
			result=sortValuesDsc().get(index).getValue();
		}

		return result;

	}

	public Integer getWorstN(int n) {

		int result=-1;

		int index=n-1;

		if(index>=0 && index<=data.size()-1) {
			result=sortValuesAsc().get(index).getValue();
		}

		return result;

	}

	public List<Entry<String, Integer>> sortValuesAsc() {
        List<Entry<String, Integer>> list_entries = new ArrayList<Entry<String, Integer>>(data.entrySet());

        Collections.sort(list_entries, new Comparator<Entry<String, Integer>>() {
            public int compare(Entry<String, Integer> obj1, Entry<String, Integer> obj2) {
                return obj1.getValue().compareTo(obj2.getValue());
            }


        });

        return list_entries;
	}

	public List<Entry<String, Integer>> sortValuesDsc() {
        List<Entry<String, Integer>> list_entries = new ArrayList<Entry<String, Integer>>(data.entrySet());

        Collections.sort(list_entries, new Comparator<Entry<String, Integer>>() {
            public int compare(Entry<String, Integer> obj1, Entry<String, Integer> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }


        });

        return list_entries;
	}


	public void print() {

		for(Entry<String,Integer> entry:data.entrySet()) {

			System.out.println(entry.getKey()+" "+entry.getValue());

		}

	}

	public void printValuesAsc() {

		List<Integer> Values=getValuesAscKey();
		int counter=1;
		for(Integer I:Values) {
    		System.out.print(I);

    		if(counter++==Values.size()) {
    			System.out.println();
    		}else {
    			System.out.print(" ");
    		}
    	}
	}

	public void printlnValuesAsc() {

		List<Integer> Values=getValuesAscKey();
		for(Integer I:Values) {
    		System.out.println(I);
    	}
	}

	public void printValuesDsc() {

		List<Integer> Values=getValuesDscKey();
		int counter=1;
		for(Integer I:Values) {
    		System.out.print(I);

    		if(counter++==Values.size()) {
    			System.out.println();
    		}else {
    			System.out.print(" ");
    		}
    	}
	}

	public void printlnValuesDsc() {

		List<Integer> Values=getValuesDscKey();
		for(Integer I:Values) {
    		System.out.println(I);
    	}
	}


	public void printdataValueSortedDsc() {
		for(Entry<String, Integer> entry:sortValuesDsc()) {
			System.out.println(entry.getKey()+" "+entry.getValue());
		}
	}

	public void printdataValueSortedAsc() {
		for(Entry<String, Integer> entry:sortValuesAsc()) {
			System.out.println(entry.getKey()+" "+entry.getValue());
		}
	}




}