let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
var cards = readLine()!.characters.split(" ").map{Int(String($0))!}
for _ in 0..<M {
    let input = readLine()!.characters.split(" ").map{Int(String($0))!}
    let (B, C) = (input[0], input[1])
    cards += (0..<B).map{_ in C}
}
cards = cards.sort{$0>$1}
print((0..<N).reduce(0){$0+cards[$1]})