#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e5 + 5;
const int mod = 998244353;
int qp(int x, int n) {
  int ans = 1;
  for (; n; n >>= 1, x = 1LL * x * x % mod)
    if (n & 1) ans = 1LL * ans * x % mod;
  return ans;
}
int inv(int x) { return qp(x, mod - 2); }
int n, m, d[mxn], s[mxn];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (int)(n); ++i) scanf("%d", &d[i]);
  sort(d, d + n);
  for (int i = 0; i < (int)(n); ++i) s[i + 1] = (s[i] + d[i] % mod) % mod;
  while (m--) {
    int a, b;
    scanf("%d %d", &a, &b);
    int ps = lower_bound(d, d + n, b) - d;
    int ans = 0;
    if (n - ps >= a) {
      (ans += 1LL * (n - ps - a) * inv(n - ps) % mod * (s[n] + mod - s[ps]) %
              mod) %= mod;
      (ans += 1LL * (n - ps + 1 - a) * inv(n - ps + 1) % mod * s[ps] % mod) %=
          mod;
    }
    printf("%d\n", ans);
  }
  return 0;
}
