def integerCards(n, m, alist, bclist):

    count = 0
    alist.sort()
    bclist.sort(key=lambda x: x[1], reverse=True)

    for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
        if count == n:
            break

    return sum(alist)

def main():
    n, m = map(int, input().split())
    alist = list(map(int, input().split()))
    bclist = [list(map(int, input().split()))for i in range(m)]
    print(integerCards(n, m, alist, bclist))

if __name__ == '__main__':
    main() def integerCards(n, m, alist, bclist):

    count = 0
    alist.sort()
    bclist.sort(key=lambda x: x[1], reverse=True)

    for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
        if count == n:
            break

    return sum(alist) integerCards count = 0 count 0 alist.sort() alist.sort alist sort bclist.sort(key=lambda x: x[1], reverse=True) bclist.sort bclist sort key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
        if count == n:
            break

     b c bclist for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
         _ range(b) range b if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
             alist[count] < c alist[count] alist count c alist[count] = c alist[count] alist count c count += 1 count 1 break if count == n:
                break
         count == n count n break if count == n:
            break

     count == n count n break return sum(alist) sum(alist) sum alist n n m m alist alist bclist bclist def main():
    n, m = map(int, input().split())
    alist = list(map(int, input().split()))
    bclist = [list(map(int, input().split()))for i in range(m)]
    print(integerCards(n, m, alist, bclist)) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m alist = list(map(int, input().split())) alist list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split list(map(int, input().split()))for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bclist = [list(map(int, input().split()))for i in range(m)] bclist [list(map(int, input().split()))for i in range(m)] print(integerCards(n, m, alist, bclist)) print integerCards(n, m, alist, bclist) integerCards n m alist bclist if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def integerCards(n, m, alist, bclist):

    count = 0
    alist.sort()
    bclist.sort(key=lambda x: x[1], reverse=True)

    for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
        if count == n:
            break

    return sum(alist) def integerCards(n, m, alist, bclist):

    count = 0
    alist.sort()
    bclist.sort(key=lambda x: x[1], reverse=True)

    for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
        if count == n:
            break

    return sum(alist) integerCards def main():
    n, m = map(int, input().split())
    alist = list(map(int, input().split()))
    bclist = [list(map(int, input().split()))for i in range(m)]
    print(integerCards(n, m, alist, bclist)) def main():
    n, m = map(int, input().split())
    alist = list(map(int, input().split()))
    bclist = [list(map(int, input().split()))for i in range(m)]
    print(integerCards(n, m, alist, bclist)) main
def integerCards(n, m, alist, bclist):

    count = 0
    alist.sort()
    bclist.sort(key=lambda x: x[1], reverse=True)

    for b, c in bclist:
        for _ in range(b):
            if alist[count] < c:
                alist[count] = c
                count += 1
            else:
                break
            if count == n:
                break
        if count == n:
            break

    return sum(alist)

def main():
    n, m = map(int, input().split())
    alist = list(map(int, input().split()))
    bclist = [list(map(int, input().split()))for i in range(m)]
    print(integerCards(n, m, alist, bclist))

if __name__ == '__main__':
    main()