//  [java]
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int m = in.nextInt();

        List<Integer> a = new ArrayList<>();
        for (int i : in.nextIntArray(n)) {
            a.add(i);
        }
        a.sort((i1, i2) -> i2 - i1);

        List<Map.Entry<Integer, Integer>> replaces = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            replaces.add(new AbstractMap.SimpleEntry<>(in.nextInt(), in.nextInt()));
        }

        replaces.sort((e1, e2) -> e2.getValue() - e1.getValue());
        List<Integer> replaced = new ArrayList<>();

        Iterator<Map.Entry<Integer, Integer>> it = replaces.iterator();
        while (replaced.size() < n && it.hasNext()) {
            Map.Entry<Integer, Integer> e = it.next();
            for (int i = 0; i < e.getKey() && replaced.size() < n; i++) {
                replaced.add(e.getValue());
            }
        }
        replaced = replaced.subList(0, Math.min(n, replaced.size()));

        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (replaced.size() > 0) {
                if (a.get(0) > replaced.get(0)) {
                    ans += a.get(0);
                    a.remove(0);
                } else {
                    ans += replaced.get(0);
                    replaced.remove(0);
                }
            } else {
                ans += a.get(0);
                a.remove(0);
            }
        }

        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}