#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m,*t=map(int,open(0).read().split())\n"
"s=sorted\n"
"a=s(t[:n])[::-1]\n"
"for c,b in s(zip(t[n+1::2],t[n::2]))[::-1]:\n"
" while(c>a[n-1])*n*b:n-=1;a[n]=c;b-=1\n"
"print(sum(a))\n"
"\"";
  system(s);
  return 0;
}            