#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
using namespace std;
std::mt19937 rnd(time(0));
const int MAX_N = 2e5 + 1;
const int mod = 998244353;
inline int qi() {
  int f = 0, fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fu = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + c - 48;
    c = getchar();
  }
  return f * fu;
}
inline long long ql() {
  long long f = 0;
  int fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fu = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + c - 48;
    c = getchar();
  }
  return f * fu;
}
inline double qd() {
  char c = getchar();
  int flag = 1;
  double ans = 0;
  while ((!(c >= '0' && c <= '9')) && c != '-') c = getchar();
  if (c == '-') flag = -1, c = getchar();
  while (c >= '0' && c <= '9') ans = ans * 10 + (c ^ 48), c = getchar();
  if (c == '.') {
    c = getchar();
    for (register int Bit = 10; c >= '0' && c <= '9';
         Bit = (Bit << 3) + (Bit << 1))
      ans += (double)(c ^ 48) * 1.0 / Bit, c = getchar();
  }
  return ans * flag;
}
int qpow(int x, int n, int mod) {
  int res = 1;
  while (n) {
    if (n & 1) res = (1ll * res * x) % mod;
    x = 1ll * x * x % mod, n >>= 1;
  }
  return res;
}
int d[MAX_N], sum[MAX_N];
int main() {
  int n = qi(), m = qi();
  for (register int i = 1, bbb = n; i <= bbb; ++i) d[i] = qi();
  sort(d + 1, d + 1 + n);
  for (register int i = 1, bbb = n; i <= bbb; ++i)
    sum[i] = (sum[i - 1] + d[i]) % mod;
  while (m--) {
    int a = qi(), b = qi();
    int x = lower_bound(d + 1, d + 1 + n, b) - d - 1, y = n - x;
    if (y < a) {
      puts("0");
      continue;
    }
    int ans = 1ll * (y - a) * (sum[n] - sum[x] + mod) % mod *
              qpow(y, mod - 2, mod) % mod;
    ans = (ans +
           1ll * (y + 1 - a) * sum[x] % mod * qpow(y + 1, mod - 2, mod) % mod) %
          mod;
    printf("%d\n", (ans % mod + mod) % mod);
  }
  return 0;
}
