#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 2e5 + 10;
const int mod = 998244353;
int n, q;
long long pref[N];
long long fact[N];
int d[N];
int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
int mult(int a, int b) { return 1ll * a * b % mod; }
int bin_pow(int a, int n) {
  if (!n) return 1;
  if (n & 1)
    return mult(a, bin_pow(a, n - 1));
  else
    return bin_pow(mult(a, a), n / 2);
}
int rev(int a) { return bin_pow(a, mod - 2); }
int f(int a, int m) {
  if (m < 0 || a < 0 || m - a + 1 < 0 || n - m - 1 < 0) return 0;
  int s = sub(m, sub(a, 1));
  s = mult(s, rev(add(m, 1)));
  return s;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> d[i];
  fact[0] = 1;
  for (int i = 1; i <= n; i++) fact[i] = mult(fact[i - 1], i);
  sort(d, d + n);
  for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + d[i];
  while (q--) {
    int a, m, b;
    cin >> a >> b;
    m = lower_bound(d, d + n, b) - d;
    int s1 = pref[m] % mod;
    int s2 = (pref[n] - pref[m]) % mod;
    m = n - m;
    s1 = mult(s1, f(a, m));
    s2 = mult(s2, f(a, m - 1));
    cout << add(s1, s2) << '\n';
  }
  return 0;
}
