#include <bits/stdc++.h>
using namespace std;
const int mxn = 200010;
const int mo = 998244353;
int n, m;
int d[mxn];
int iv[mxn];
long long s[mxn];
void initiv(int n) {
  iv[1] = 1;
  for (int i = 2; i <= n; i++) {
    iv[i] = (long long)(mo - mo / i) * iv[mo % i] % mo;
  }
}
void sol() {
  int a, b;
  scanf("%d%d", &a, &b);
  int l = 0, r = n;
  while (l < r) {
    int mi = (l + r + 1) / 2;
    if (d[mi] >= b)
      l = mi;
    else
      r = mi - 1;
  }
  int x = l;
  l = n - x;
  if (x < a) {
    printf("0\n");
    return;
  }
  long long ans =
      (s[x] * (x - a) % mo * iv[x] +
       (long long)(s[n] - s[x] + mo) * (x - a + 1) % mo * iv[x + 1]) %
      mo;
  printf("%lld\n", ans);
}
bool cmp(int x, int y) { return x > y; }
int main() {
  initiv(200000);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
  }
  sort(d + 1, d + 1 + n, cmp);
  s[0] = 0;
  for (int i = 1; i <= n; i++) s[i] = (s[i - 1] + d[i]) % mo;
  for (int i = 1; i <= m; i++) {
    sol();
  }
  return 0;
}
