#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
const int mod = 998244353;
long long n, m;
vector<long long> v;
long long cnt[N];
long long pre[N];
long long fac[N];
long long sq(long long a) { return (a * a) % mod; }
long long bin(long long a, long long b) {
  if (b == 0) return 1;
  if (b & 1) return (a * sq(bin(a, b >> 1))) % mod;
  return sq(bin(a, b >> 1)) % mod;
}
long long ncr(long long a, long long b) {
  if (a < b) return 0;
  return fac[a] * bin((fac[b] * fac[a - b]) % mod, mod - 2) % mod;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = fac[i - 1] * i;
    fac[i] %= mod;
  }
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    long long k;
    cin >> k;
    v.push_back(k);
  }
  sort(v.begin(), v.end());
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + v[i - 1];
    pre[i] %= mod;
  }
  while (m--) {
    long long ans = 0;
    long long a, b;
    cin >> a >> b;
    long long big = v.end() - lower_bound(v.begin(), v.end(), b);
    long long small = n - big;
    if (big < a) {
      cout << 0 << endl;
      continue;
    }
    long long bb = 1;
    bb -= (a * bin(big, mod - 2)) % mod;
    bb += mod;
    bb %= mod;
    long long ss = 1;
    ss -= (a * bin(big + 1, mod - 2)) % mod;
    ss += mod;
    ss %= mod;
    ss *= pre[small];
    bb *= (pre[n] - pre[small] + mod) % mod;
    cout << (ss + bb) % mod << endl;
  }
}
