#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
long long n, m, i, x, y, z, l, w, p, q, Ans, sum, cnt;
long long a[200010], s[200010], mi[200010], ni[200010];
inline int Abs(int x) { return (x < 0) ? -x : x; }
inline void Swap(int &a, int &b) { a ^= b ^= a ^= b; }
inline int Min(int a, int b) { return (a < b) ? a : b; }
inline int Max(int a, int b) { return (a > b) ? a : b; }
inline long long read() {
  long long p = 0, f = 1;
  char c = getchar();
  while (c < 48 || c > 57) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) p = (p << 1) + (p << 3) + c - 48, c = getchar();
  return p * f;
}
inline long long Mi(long long x, long long y) {
  long long p = x, t = 1, Res = 1;
  for (; t <= y; (t & y) ? Res = (Res * p) % 998244353 : 0,
                           p = (p * p) % 998244353, t <<= 1)
    ;
  return Res;
}
int main() {
  n = read();
  m = read();
  for (i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + 1 + n);
  for (i = 1; i <= n; i++) s[i] = (s[i - 1] + a[i]) % 998244353;
  for (i = 1; i <= m; i++) {
    x = read();
    y = read();
    l = lower_bound(a + 1, a + 1 + n, y) - a;
    if (l > n) {
      puts("0");
      continue;
    }
    if (n - l + 1 < x) {
      puts("0");
      continue;
    }
    Ans = 0;
    p = n - l + 1 - x;
    p = p * Mi(n - l + 1, 998244353 - 2) % 998244353;
    Ans = (Ans + p * (s[n] - s[l - 1] + 998244353) % 998244353) % 998244353;
    p = (n - l + 2 - x);
    p = p * Mi(n - l + 2, 998244353 - 2) % 998244353;
    p = (p * s[l - 1]) % 998244353;
    Ans = (Ans + p) % 998244353;
    printf("%lld\n", Ans);
  }
  return 0;
}
