#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N];
struct node {
  int x, y;
} sm[N];
bool cmp(node x, node y) { return x.x < y.x; }
int main() {
  int s, b;
  cin >> s >> b;
  for (int i = 0; i < s; i++) cin >> a[i];
  for (int i = 0; i < b; i++) cin >> sm[i].x >> sm[i].y;
  sort(sm, sm + b, cmp);
  for (int i = 0; i < s; i++) {
    long long sum = 0;
    for (int j = 0; j < b; j++) {
      if (sm[j].x <= a[i])
        sum += (long long)sm[j].y;
      else
        break;
    }
    cout << sum << endl;
  }
  return 0;
}
