def main():
	N, M = [int(x) for x in input().split(" ")]
	A = [int(a) for a in input().split(" ")]
	A.sort()
	overwrite = []
	for i in range(M):
		B, C = [int(x) for x in input().split(" ")]
		overwrite.append({
			"count": B,
			"number": C
		})
	overwrite.sort(key=lambda o: -o["number"])
	j = 0
	k = 0
	flag = False
	while not flag and j < len(A) and k < len(overwrite):
		o = overwrite[k]
		for m in range(o["count"]):
			if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		k += 1

	print(sum(A))

main() def main():
	N, M = [int(x) for x in input().split(" ")]
	A = [int(a) for a in input().split(" ")]
	A.sort()
	overwrite = []
	for i in range(M):
		B, C = [int(x) for x in input().split(" ")]
		overwrite.append({
			"count": B,
			"number": C
		})
	overwrite.sort(key=lambda o: -o["number"])
	j = 0
	k = 0
	flag = False
	while not flag and j < len(A) and k < len(overwrite):
		o = overwrite[k]
		for m in range(o["count"]):
			if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		k += 1

	print(sum(A)) main int(x) for x in input().split(" ") for x in input().split(" ") x input().split(" ") ().split () input split " " for x in input().split(" ") int(x) int x N, M = [int(x) for x in input().split(" ")] N [int(x) for x in input().split(" ")] M int(a) for a in input().split(" ") for a in input().split(" ") a input().split(" ") ().split () input split " " for a in input().split(" ") int(a) int a A = [int(a) for a in input().split(" ")] A [int(a) for a in input().split(" ")] A.sort() A.sort A sort overwrite = [] overwrite [] for i in range(M):
		B, C = [int(x) for x in input().split(" ")]
		overwrite.append({
			"count": B,
			"number": C
		})
	 i range(M) range M int(x) for x in input().split(" ") for x in input().split(" ") x input().split(" ") ().split () input split " " for x in input().split(" ") int(x) int x B, C = [int(x) for x in input().split(" ")] B [int(x) for x in input().split(" ")] C overwrite.append({
			"count": B,
			"number": C
		}) overwrite.append overwrite append {
			"count": B,
			"number": C
		} "count" "count" B "number" "number" C overwrite.sort(key=lambda o: -o["number"]) overwrite.sort overwrite sort key=lambda o: -o["number"] key lambda o: -o["number"] -o["number"] o["number"] o "number" o j = 0 j 0 k = 0 k 0 flag = False flag False while not flag and j < len(A) and k < len(overwrite):
		o = overwrite[k]
		for m in range(o["count"]):
			if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		k += 1

	 not flag and j < len(A) and k < len(overwrite) not flag and j < len(A) not flag flag j < len(A) j len(A) len A k < len(overwrite) k len(overwrite) len overwrite o = overwrite[k] o overwrite[k] overwrite k for m in range(o["count"]):
			if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		 m range(o["count"]) range o["count"] o "count" if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		 j < len(A) and A[j] <= o["number"] j < len(A) j len(A) len A A[j] <= o["number"] A[j] A j o["number"] o "number" A[j] = o["number"] A[j] A j o["number"] o "number" j += 1 j 1 flag = True flag True k += 1 k 1 print(sum(A)) print sum(A) sum A main() main def main():
	N, M = [int(x) for x in input().split(" ")]
	A = [int(a) for a in input().split(" ")]
	A.sort()
	overwrite = []
	for i in range(M):
		B, C = [int(x) for x in input().split(" ")]
		overwrite.append({
			"count": B,
			"number": C
		})
	overwrite.sort(key=lambda o: -o["number"])
	j = 0
	k = 0
	flag = False
	while not flag and j < len(A) and k < len(overwrite):
		o = overwrite[k]
		for m in range(o["count"]):
			if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		k += 1

	print(sum(A)) def main():
	N, M = [int(x) for x in input().split(" ")]
	A = [int(a) for a in input().split(" ")]
	A.sort()
	overwrite = []
	for i in range(M):
		B, C = [int(x) for x in input().split(" ")]
		overwrite.append({
			"count": B,
			"number": C
		})
	overwrite.sort(key=lambda o: -o["number"])
	j = 0
	k = 0
	flag = False
	while not flag and j < len(A) and k < len(overwrite):
		o = overwrite[k]
		for m in range(o["count"]):
			if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		k += 1

	print(sum(A)) main
def main():
	N, M = [int(x) for x in input().split(" ")]
	A = [int(a) for a in input().split(" ")]
	A.sort()
	overwrite = []
	for i in range(M):
		B, C = [int(x) for x in input().split(" ")]
		overwrite.append({
			"count": B,
			"number": C
		})
	overwrite.sort(key=lambda o: -o["number"])
	j = 0
	k = 0
	flag = False
	while not flag and j < len(A) and k < len(overwrite):
		o = overwrite[k]
		for m in range(o["count"]):
			if j < len(A) and A[j] <= o["number"]:
				A[j] = o["number"]
				j += 1
			else:
				flag = True
		k += 1

	print(sum(A))

main()
