def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    dic = {}
    for i in range(n):
        if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
    for i in range(m):
        b,c = map(int,input().split())
        if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
    cnt = 0
    ans = 0
    for k in sorted(dic.keys(),reverse=True):
        if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return

if __name__ == "__main__":
    main() def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    dic = {}
    for i in range(n):
        if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
    for i in range(m):
        b,c = map(int,input().split())
        if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
    cnt = 0
    ans = 0
    for k in sorted(dic.keys(),reverse=True):
        if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return main n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split dic = {} dic {} for i in range(n):
        if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
     i range(n) range n if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
     a[i] not in dic.keys() a[i] a i dic.keys() dic.keys dic keys dic[a[i]] = 1 dic[a[i]] dic a[i] a i 1 dic[a[i]] += 1 dic[a[i]] dic a[i] a i 1 for i in range(m):
        b,c = map(int,input().split())
        if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
     i range(m) range m b,c = map(int,input().split()) b map(int,input().split()) map int input().split() ().split () input split c if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
     c not in dic.keys() c dic.keys() dic.keys dic keys dic[c] = b dic[c] dic c b dic[c] += b dic[c] dic c b cnt = 0 cnt 0 ans = 0 ans 0 for k in sorted(dic.keys(),reverse=True):
        if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return k sorted(dic.keys(),reverse=True) sorted dic.keys() dic.keys dic keys reverse=True reverse True if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return cnt + dic[k] < n cnt + dic[k] cnt dic[k] dic k n ans += dic[k]*k ans dic[k]*k dic[k] dic k k cnt = cnt + dic[k] cnt cnt + dic[k] cnt dic[k] dic k ans += k *(n-cnt) ans k *(n-cnt) k n-cnt n cnt print(ans) print ans return if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    dic = {}
    for i in range(n):
        if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
    for i in range(m):
        b,c = map(int,input().split())
        if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
    cnt = 0
    ans = 0
    for k in sorted(dic.keys(),reverse=True):
        if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    dic = {}
    for i in range(n):
        if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
    for i in range(m):
        b,c = map(int,input().split())
        if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
    cnt = 0
    ans = 0
    for k in sorted(dic.keys(),reverse=True):
        if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return main
def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    dic = {}
    for i in range(n):
        if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
    for i in range(m):
        b,c = map(int,input().split())
        if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
    cnt = 0
    ans = 0
    for k in sorted(dic.keys(),reverse=True):
        if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return

if __name__ == "__main__":
    main()
