def main():
    n,m=map(int,input().split())
    a=sorted(map(int,input().split()))
    bc=[list(map(int,input().split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b,c in bc:
        for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
    print(sum(a))
    
if __name__ == "__main__":
    main() def main():
    n,m=map(int,input().split())
    a=sorted(map(int,input().split()))
    bc=[list(map(int,input().split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b,c in bc:
        for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
    print(sum(a))
     main n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=sorted(map(int,input().split())) a sorted(map(int,input().split())) sorted map(int,input().split()) map int input().split() ().split () input split list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split bc=[list(map(int,input().split())) for _ in range(m)] bc [list(map(int,input().split())) for _ in range(m)] bc.sort(key=lambda x: x[1], reverse=True) bc.sort bc sort key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True i = 0 i 0 for b,c in bc:
        for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
     b c bc for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
     _ range(b) range b if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
     i < len(a) and a[i] < c i < len(a) i len(a) len a a[i] < c a[i] a i c a[i] = c a[i] a i c i += 1 i 1 print(sum(a)) print sum(a) sum a return print(sum(a)) print sum(a) sum a if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n,m=map(int,input().split())
    a=sorted(map(int,input().split()))
    bc=[list(map(int,input().split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b,c in bc:
        for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
    print(sum(a))
     def main():
    n,m=map(int,input().split())
    a=sorted(map(int,input().split()))
    bc=[list(map(int,input().split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b,c in bc:
        for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
    print(sum(a))
     main
def main():
    n,m=map(int,input().split())
    a=sorted(map(int,input().split()))
    bc=[list(map(int,input().split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b,c in bc:
        for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
    print(sum(a))
    
if __name__ == "__main__":
    main()