import Foundation

let args = readLine()!.split(separator: " ")
let N = Int(args[0])!
let M = Int(args[1])!
var A = readLine()!.split(separator: " ").map { Int($0)! }

A.sort()
for _ in 1 ... M { // j
    let args = readLine()!.split(separator: " ")
    let B = Int(args[0])!
    let C = Int(args[1])!
    var replace = 0
    for b in 0 ..< B {
        if C < A[b] { break }
        replace += 1
    }
    if 0 < replace {
        A.removeFirst(replace)
        var n = 0
        while n < N {
            if C <= A[n] { break }
            n += 1
        }
        for _ in 0 ..< replace {
            A.insert(C, at: n)
        }
    }
}
let answer = A.reduce(0, { $0 + $1 })

print(answer)
