#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double PI = 3.1415926535897932;
const int dir[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1};
const int maxn = 2e5 + 5;
const int MOD = 998244353;
int n, m;
int d[maxn];
long long sum[maxn];
long long qpow(long long a, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * a % MOD;
    a = a * a % MOD;
    p >>= 1;
  }
  return ans;
}
long long inv(long long a) { return qpow(a, MOD - 2); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
  sort(d + 1, d + 1 + n);
  for (int i = 1; i <= n; i++) sum[i] = (sum[i - 1] + d[i]) % MOD;
  while (m--) {
    long long A, B;
    scanf("%lld%lld", &A, &B);
    int st = lower_bound(d + 1, d + 1 + n, B) - d;
    if (n - st + 1 < A) {
      printf("0\n");
      continue;
    }
    long long k = n - st + 1;
    long long kk = (k - A) * inv(k) % MOD;
    long long ans = (sum[n] - sum[st - 1]) % MOD * kk % MOD;
    kk = (k - A + 1) * inv(k + 1) % MOD;
    ans = (ans + sum[st - 1] * kk % MOD) % MOD;
    ans = (ans + MOD) % MOD;
    printf("%lld\n", ans);
  }
  return 0;
}
