#include <bits/stdc++.h>
const int MOD = 998244353;
int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
int mult(int a, int b) { return (long long)a * b % MOD; }
int exp(int a, long long x) {
  int res = 1;
  while (x) {
    if (x & 1) res = mult(res, a);
    a = mult(a, a);
    x /= 2;
  }
  return res;
}
int divi(int a, int b) { return mult(a, exp(b, MOD - 2)); }
const int SIZE = 200005;
int n, m;
int a[SIZE];
long long sum[SIZE];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  std::sort(a, a + n);
  for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i - 1];
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    int in = std::lower_bound(a, a + n, y) - a;
    int res = 0;
    if (n - in >= x) {
      res = mult(sub(1, divi(x, n - in + 1)), sum[in] % MOD);
      res = add(res, mult(sub(1, divi(x, n - in)), (sum[n] - sum[in]) % MOD));
    }
    printf("%d\n", res);
  }
  return 0;
}
