use std::cmp;
use std::collections::BTreeMap;
use std::collections::BinaryHeap; // 優先度付きキュー
use std::collections::HashMap; // 連想配列
use std::collections::HashSet; // 連想配列 キーのみ
use std::collections::VecDeque; // キュー or スタック
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize,
        a: [usize;n],
        operation: [(usize,usize);m]
    }

    let mut a = a;
    a.sort();

    let mut operation = operation;
    operation.sort_by(|x, y| {
        if x.1 > y.1 {
            std::cmp::Ordering::Less
        } else if x.1 == y.1 {
            y.0.cmp(&x.0)
        } else {
            std::cmp::Ordering::Greater
        }
    });

    let mut ans = 0;
    let mut replaced = 0;

    for o in &operation {
        let b = o.0;
        let c = o.1;
        let r_index = bin_search(&a[replaced..], c);
        if a[r_index + replaced] <= c {
            let new_replaced = cmp::min(b, r_index + 1) + replaced;
            /*
            println!(
                "{} {} {} {} {:?}",
                new_replaced,
                replaced,
                r_index,
                b,
                &a[replaced..n - 1]
            );
            */
            if new_replaced > replaced {
                for i in replaced..new_replaced {
                    ans += c;
                }
            }
            replaced = new_replaced;

            if replaced >= n {
                break;
            }
        }
    }

    if replaced < n {
        for i in replaced..n {
            ans += a[i];
        }
    }

    println!("{:?}", ans);
}

fn bin_search(slice: &[usize], num: usize) -> usize {
    let mut min = 0;
    let mut max = slice.len() - 1;
    while max - min > 1 {
        let mid = (max + min) / 2;
        if slice[mid] > num {
            max = mid;
        } else {
            min = mid;
        }
    }
    if slice[max] > num {
        return min;
    } else {
        return max;
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 12668