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

let A = readLine()!.split(separator: " ").map { Int($0)! }.sorted()
var B: [[Int]] = []

for i in 0..<M {
  B.append(readLine()!.split(separator: " ").map { Int($0)! })
}

B = B.sorted { $0[1] > $1[1] }

var j = 0
var sum = 0

for i in 0..<A.count {
  if j < B.count && B[j][0] == 0 {
    j += 1
  }
  if j >= B.count || B[j][1] <= A[i] {
    sum += A[i]
  } else {
    B[j][0] -= 1
    sum += B[j][1]
  }
}
print(sum)