#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int mod = 998244353;
template <class T>
inline T read() {
  char ch;
  bool flag = 0;
  T x = 0;
  while (ch = getchar(), !isdigit(ch))
    if (ch == '-') flag = 1;
  while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
  return flag ? -x : x;
}
struct {
  inline operator long long() { return read<long long>(); }
  inline operator int() { return read<int>(); }
  inline operator bool() { return read<bool>(); }
  inline operator double() {
    double _tmp;
    return scanf("%lf", &_tmp), _tmp;
  }
  template <class T>
  inline void operator()(T &x) {
    x = *this;
  }
  template <class T, class... A>
  inline void operator()(T &x, A &...a) {
    x = *this, this->operator()(a...);
  }
} IN;
template <class T>
inline void chkmax(T &x, T y) {
  if (x < y) x = y;
}
template <class T>
inline void chkmin(T &x, T y) {
  if (x > y) x = y;
}
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int dec(int x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline void sub(int &x, int y) {
  x -= y;
  if (x < 0) x += mod;
}
inline void pls(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
inline int modpow(int x, int y, int res = 1) {
  if (y == -1) y = mod - 2;
  for (; y; y >>= 1, x = mul(x, x))
    if (y & 1) res = mul(res, x);
  return res;
}
const int N = 1e6 + 5;
int n, m, a, b, d[N], sum[N];
int main() {
  IN(n, m);
  for (int i = 1; i <= n; ++i) IN(d[i]);
  std::sort(d + 1, d + 1 + n);
  for (int i = 1; i <= n; ++i) sum[i] = add(sum[i - 1], d[i] % mod);
  while (m--) {
    IN(a, b);
    int pos = lower_bound(d + 1, d + 1 + n, b) - d - 1, ans = 0;
    if (a > n - pos)
      puts("0");
    else {
      pls(ans, mul(sum[pos], mul(n - pos - a + 1, modpow(n - pos + 1, -1))));
      pls(ans,
          mul(dec(sum[n], sum[pos]), mul(n - pos - a, modpow(n - pos, -1))));
      printf("%d\n", ans);
    }
  }
  return 0;
}
