#!/usr/bin/env python
# coding: utf-8

# In[14]:


N,M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))


# In[15]:


bc_sorted = sorted(BC, key=lambda x:x[1], reverse=True)
mylist = [a for a in A]
for i in range(M):
    mylist += [bc_sorted[i][1]]*bc_sorted[i][0]
    if len(mylist) > N*2:
        break
ans = sorted(mylist, reverse=True)[:N]
print(sum(ans))


# In[ ]:



 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 BC = [] BC [] for _ in range(M):
    BC.append(list(map(int, input().split())))


# In[15]: _ range(M) range M BC.append(list(map(int, input().split()))) BC.append BC append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bc_sorted = sorted(BC, key=lambda x:x[1], reverse=True) bc_sorted sorted(BC, key=lambda x:x[1], reverse=True) sorted BC key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True a for a in A for a in A a A for a in A a mylist = [a for a in A] mylist [a for a in A] for i in range(M):
    mylist += [bc_sorted[i][1]]*bc_sorted[i][0]
    if len(mylist) > N*2:
        break i range(M) range M mylist += [bc_sorted[i][1]]*bc_sorted[i][0] mylist [bc_sorted[i][1]]*bc_sorted[i][0] [bc_sorted[i][1]] bc_sorted[i][1] [i] bc_sorted i 1 bc_sorted[i][0] [i] bc_sorted i 0 if len(mylist) > N*2:
        break len(mylist) > N*2 len(mylist) len mylist N*2 N 2 break ans = sorted(mylist, reverse=True)[:N] ans sorted(mylist, reverse=True)[:N] (mylist, reverse=True) sorted mylist reverse=True reverse True :N N print(sum(ans)) print sum(ans) sum ans mylist += [bc_sorted[i][1]]*bc_sorted[i][0] [bc_sorted[i][1]]*bc_sorted[i][0] mylist A = list(map(int, input().split())) list(map(int, input().split())) A ans = sorted(mylist, reverse=True)[:N] sorted(mylist, reverse=True)[:N] ans BC = [] [] BC mylist = [a for a in A] [a for a in A] mylist bc_sorted = sorted(BC, key=lambda x:x[1], reverse=True) sorted(BC, key=lambda x:x[1], reverse=True) bc_sorted N,M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M
#!/usr/bin/env python
# coding: utf-8

# In[14]:


N,M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))


# In[15]:


bc_sorted = sorted(BC, key=lambda x:x[1], reverse=True)
mylist = [a for a in A]
for i in range(M):
    mylist += [bc_sorted[i][1]]*bc_sorted[i][0]
    if len(mylist) > N*2:
        break
ans = sorted(mylist, reverse=True)[:N]
print(sum(ans))


# In[ ]:




