#include <bits/stdc++.h>
using namespace std;
long long Pow(long long x, long long p) {
  long long ret = 1;
  for (; p; p >>= 1, x = x * x % 998244353)
    if (p & 1) ret = ret * x % 998244353;
  return ret;
}
int d[202333];
long long SS[202333];
int main() {
  int n, m, a, b;
  long long S = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", d + i);
  sort(d + 1, d + n + 1);
  for (int i = 1; i <= n; ++i) S += d[i], SS[i] = S;
  S %= 998244353;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &a, &b);
    int pos = lower_bound(d + 1, d + n + 1, b) - d;
    int X = n - pos + 1;
    if (X < a)
      puts("0");
    else
      printf("%d\n",
             (int)((((SS[n] - SS[pos - 1]) % 998244353 * (X - a) % 998244353 *
                     Pow(X, 998244353 - 2) % 998244353) +
                    ((SS[pos - 1]) % 998244353 * (X - a + 1) % 998244353 *
                     Pow(X + 1, 998244353 - 2) % 998244353)) %
                   998244353));
  }
  return 0;
}
