You have N cards. On the i-th card, an integer A_i is written.

For each j = 1, 2, ..., M in this order, you will perform the following operation once:

Operation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j.

Find the maximum possible sum of the integers written on the N cards after the M operations.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* 1 \leq A_i, C_i \leq 10^9
* 1 \leq B_i \leq N

Input

Input is given from Standard Input in the following format:


N M
A_1 A_2 ... A_N
B_1 C_1
B_2 C_2
\vdots
B_M C_M


Output

Print the maximum possible sum of the integers written on the N cards after the M operations.

Examples

Input

3 2
5 1 4
2 3
1 5


Output

14


Input

10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4


Output

338


Input

3 2
100 100 100
3 99
3 99


Output

300


Input

11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000


Output

10000000001
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        Integer[] a = new Integer[n];
        
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        
        
        Arrays.sort(a);
        
        List<Pair<Integer,Integer>> list = new ArrayList<Pair<Integer,Integer>>();
        
        for(int i = 0; i < m; i++){
            list.add(new Pair<>(sc.nextInt(), sc.nextInt()));
        }
        
        list.sort((x,y) -> y.getValue() - x.getValue());
        
        //一回変えたやつを変えるのは無駄
        
        int next = 0; //次ぎかえるもの
        
        for(Pair<Integer, Integer> pair : list){
            int b = pair.getKey(); //個数
            int c = pair.getValue(); //値

            for(int i = next; i < n; i++){
                if(b == 0){
                    next = i;
                    break;
                }
                
                if(a[i] < c){
                    a[i] = c;
                    b--;
                }else{
                    next = i;
                    break;
                }
            }
        }

        System.out.println(Arrays.stream(a).mapToLong(x -> (long)x).sum());
        
    }
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
 
    public Pair(K key, V value) {
        super(key, value);
    }
 
    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }


class UnionFind {
	int[] par;
	
	public UnionFind(int n) {
		par = new int[n];
		
		Arrays.fill(par,-1);
	}
	
	int root(int x) {
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x,int y) {
	    x = root(x);
	    y = root(y);
	    
	    if(x != y){
	        if(par[x] > par[y]){
	            int tmp = x;
	            x = y;
	            y = tmp;
	        }
	        par[x] += par[y];
	        par[y] = x;
	    }
	}
	
	boolean same(int x,int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
	
	int size(int x){
		return -par[root(x)];
	}
}