#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()
    a = LI()

    a.sort()

    counter = cl.Counter({})

    for i in range(m):
        b, c = MI()
        counter.update({c: b})
    items = counter.items()
    items = sorted(items, key=lambda x: x[0], reverse=True)
    values, counts = map(list, zip(*items))

    lergest = 0
    finish = False
    for i in range(n):

        while not finish and a[i] > values[lergest]:
            lergest += 1
            if lergest == len(values):
                finish = True
                break
        if finish:
            break
        a[i] = values[lergest]
        counts[lergest] -= 1
        if counts[lergest] == 0:
            lergest += 1
            if lergest == len(values):
                break
    print(sum(a))


main() import collections as cl collections import sys sys def II():
    return int(sys.stdin.readline()) II return int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline def MI():
    return map(int, sys.stdin.readline().split()) MI return map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def LI():
    return list(map(int, sys.stdin.readline().split())) LI return list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def main():
    n, m = MI()
    a = LI()

    a.sort()

    counter = cl.Counter({})

    for i in range(m):
        b, c = MI()
        counter.update({c: b})
    items = counter.items()
    items = sorted(items, key=lambda x: x[0], reverse=True)
    values, counts = map(list, zip(*items))

    lergest = 0
    finish = False
    for i in range(n):

        while not finish and a[i] > values[lergest]:
            lergest += 1
            if lergest == len(values):
                finish = True
                break
        if finish:
            break
        a[i] = values[lergest]
        counts[lergest] -= 1
        if counts[lergest] == 0:
            lergest += 1
            if lergest == len(values):
                break
    print(sum(a)) main n, m = MI() n MI() MI m a = LI() a LI() LI a.sort() a.sort a sort counter = cl.Counter({}) counter cl.Counter({}) cl.Counter cl Counter {} for i in range(m):
        b, c = MI()
        counter.update({c: b})
     i range(m) range m b, c = MI() b MI() MI c counter.update({c: b}) counter.update counter update {c: b} c c b items = counter.items() items counter.items() counter.items counter items items = sorted(items, key=lambda x: x[0], reverse=True) items sorted(items, key=lambda x: x[0], reverse=True) sorted items key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x reverse=True reverse True values, counts = map(list, zip(*items)) values map(list, zip(*items)) map list zip(*items) zip *items items counts lergest = 0 lergest 0 finish = False finish False for i in range(n):

        while not finish and a[i] > values[lergest]:
            lergest += 1
            if lergest == len(values):
                finish = True
                break
        if finish:
            break
        a[i] = values[lergest]
        counts[lergest] -= 1
        if counts[lergest] == 0:
            lergest += 1
            if lergest == len(values):
                break
     i range(n) range n while not finish and a[i] > values[lergest]:
            lergest += 1
            if lergest == len(values):
                finish = True
                break
         not finish and a[i] > values[lergest] not finish finish a[i] > values[lergest] a[i] a i values[lergest] values lergest lergest += 1 lergest 1 if lergest == len(values):
                finish = True
                break
         lergest == len(values) lergest len(values) len values finish = True finish True break if finish:
            break
         finish break a[i] = values[lergest] a[i] a i values[lergest] values lergest counts[lergest] -= 1 counts[lergest] counts lergest 1 if counts[lergest] == 0:
            lergest += 1
            if lergest == len(values):
                break
     counts[lergest] == 0 counts[lergest] counts lergest 0 lergest += 1 lergest 1 if lergest == len(values):
                break
     lergest == len(values) lergest len(values) len values break print(sum(a)) print sum(a) sum a main() main def main():
    n, m = MI()
    a = LI()

    a.sort()

    counter = cl.Counter({})

    for i in range(m):
        b, c = MI()
        counter.update({c: b})
    items = counter.items()
    items = sorted(items, key=lambda x: x[0], reverse=True)
    values, counts = map(list, zip(*items))

    lergest = 0
    finish = False
    for i in range(n):

        while not finish and a[i] > values[lergest]:
            lergest += 1
            if lergest == len(values):
                finish = True
                break
        if finish:
            break
        a[i] = values[lergest]
        counts[lergest] -= 1
        if counts[lergest] == 0:
            lergest += 1
            if lergest == len(values):
                break
    print(sum(a)) def main():
    n, m = MI()
    a = LI()

    a.sort()

    counter = cl.Counter({})

    for i in range(m):
        b, c = MI()
        counter.update({c: b})
    items = counter.items()
    items = sorted(items, key=lambda x: x[0], reverse=True)
    values, counts = map(list, zip(*items))

    lergest = 0
    finish = False
    for i in range(n):

        while not finish and a[i] > values[lergest]:
            lergest += 1
            if lergest == len(values):
                finish = True
                break
        if finish:
            break
        a[i] = values[lergest]
        counts[lergest] -= 1
        if counts[lergest] == 0:
            lergest += 1
            if lergest == len(values):
                break
    print(sum(a)) main def II():
    return int(sys.stdin.readline()) def II():
    return int(sys.stdin.readline()) II def MI():
    return map(int, sys.stdin.readline().split()) def MI():
    return map(int, sys.stdin.readline().split()) MI def LI():
    return list(map(int, sys.stdin.readline().split())) def LI():
    return list(map(int, sys.stdin.readline().split())) LI
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()
    a = LI()

    a.sort()

    counter = cl.Counter({})

    for i in range(m):
        b, c = MI()
        counter.update({c: b})
    items = counter.items()
    items = sorted(items, key=lambda x: x[0], reverse=True)
    values, counts = map(list, zip(*items))

    lergest = 0
    finish = False
    for i in range(n):

        while not finish and a[i] > values[lergest]:
            lergest += 1
            if lergest == len(values):
                finish = True
                break
        if finish:
            break
        a[i] = values[lergest]
        counts[lergest] -= 1
        if counts[lergest] == 0:
            lergest += 1
            if lergest == len(values):
                break
    print(sum(a))


main()
