#include <bits/stdc++.h>
using namespace std;
int N, M;
int D[202020];
signed long long S[202020];
const signed long long mo = 998244353;
int A, B;
signed long long modpow(signed long long a, signed long long n = mo - 2) {
  signed long long r = 1;
  a %= mo;
  while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a % mo, n >>= 1;
  return r;
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> M;
  for (i = 0; i < (N); i++) cin >> D[i];
  sort(D, D + N);
  for (i = 0; i < (N); i++) S[i + 1] = S[i] + D[i];
  for (i = 0; i < (M); i++) {
    cin >> A >> B;
    x = lower_bound(D, D + N, B) - D;
    int over = N - x;
    if (over < A) {
      cout << 0 << endl;
      continue;
    }
    signed long long ret = 0;
    signed long long X = (S[N] - S[x]) % mo;
    ret += X * (over - A) % mo * modpow(over);
    if (x) {
      signed long long X = S[x] % mo;
      ret += X * (over + 1 - A) % mo * modpow(over + 1);
    }
    cout << ret % mo << endl;
  }
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
