_Heap = {
  heap: [],
  compare: (a, b) => a < b,
  create(arr, desc) {
    this.heap = [0];
    if (desc) {
      this.compare = (a, b) => a > b;
    }
    for (var i = 0; i < arr.length; i++) {
      this.push(arr[i] * 1);
    }
  },
  push(v) {
    var idx = this.heap.length;
    while (idx > 1) {
      var parent = ~~(idx / 2);
      if (this.compare(v, this.heap[parent])) {
        this.heap[idx] = this.heap[parent];
        idx = parent;
      } else {
        break;
      }
    }
    this.heap[idx] = v;
  },
  pop() {
    if (this.heap.length == 1) {
      return;
    } else if (this.heap.length == 2) {
      return this.heap.pop();
    }

    var val = this.heap[1];
    var last = this.heap.pop();
    var idx = 1;
    while (true) {
      var left = idx * 2;
      var right = idx * 2 + 1;
      var next = idx;
      if (left < this.heap.length && this.compare(this.heap[left], last)) {
        next = left;
      }
      if (
        right < this.heap.length &&
        this.compare(this.heap[right], last) &&
        this.compare(this.heap[right], this.heap[left])
      ) {
        next = right;
      }
      if (next != idx) {
        this.heap[idx] = this.heap[next];
        idx = next;
      } else {
        break;
      }
    }
    this.heap[idx] = last;
    return val;
  }
};

inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
N = l[0] * 1
M = l[1] * 1
_Heap.create(inp.shift().split(' '))
for (i=0; i<M; i++) {
  l = inp[i].split(' ')
  b = l[0] * 1
  c = l[1] * 1
  while(b--) {
      a = _Heap.heap[1]
      if (a > c) {
          break;
      } else {
          _Heap.pop()
          _Heap.push(c)
      }
  }
}
sum = 0
for(i=0;i<_Heap.heap.length;i++) {
    sum += _Heap.heap[i]
}
console.log(sum)
