#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long n, m;
long long damage[200005];
long long prefix[200005];
long long powr(long long r, long long k) {
  long long z = 1;
  while (k) {
    if (k & 1) z = (z * r) % MOD;
    r = (r * r) % MOD;
    k >>= 1;
  }
  return z;
}
long long divide(long long x, long long y) {
  return ((x * powr(y, MOD - 2)) % MOD);
}
int main() {
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) cin >> damage[i];
  sort(damage, damage + n);
  prefix[0] = 0;
  for (long long i = 0; i < n; ++i) {
    prefix[i + 1] = prefix[i] + damage[i];
    prefix[i + 1] %= MOD;
  }
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    long long low = 0;
    long long high = n - 1;
    while (low < high) {
      long long mid = (low + high) / 2;
      if (damage[mid] < b)
        low = mid + 1;
      else
        high = mid;
    }
    long long gMon = n - low;
    if (gMon < a) {
      cout << 0 << endl;
      continue;
    }
    long long ans = divide(gMon + 1 - a, gMon + 1);
    ans *= prefix[low];
    ans %= MOD;
    long long nAdd = divide(gMon - a, gMon);
    nAdd *= (MOD + prefix[n] - prefix[low]);
    nAdd %= MOD;
    ans += nAdd;
    ans %= MOD;
    cout << ans << endl;
  }
}
