#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, MOD = 998244353;
int n, m, a[N], b[N], d[N];
long long sum[N], ans;
int bin(int x, int p) {
  int res = 1;
  for (int b = x; p; p >>= 1, b = 1ll * b * b % MOD)
    if (p & 1) res = 1ll * res * b % MOD;
  return res;
}
int getpos(int x) {
  int l = 1, r = n + 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (d[mid] < x)
      l = mid + 1;
    else
      r = mid;
  }
  return l;
}
int main() {
  cin >> 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];
  }
  for (int i = 1; i <= m; i++) {
    int a, b;
    ans = 0;
    scanf("%d%d", &a, &b);
    int pos = lower_bound(d + 1, d + 1 + n, b) - d;
    int big = n - pos + 1;
    if (a > big)
      ans = 0;
    else {
      ans += 1ll * (sum[n] - sum[pos - 1]) % MOD * (big - a) % MOD *
             bin(big, MOD - 2) % MOD;
      ans += 1ll * (sum[pos - 1]) % MOD * (big + 1 - a) % MOD *
             bin(big + 1, MOD - 2) % MOD;
    }
    printf("%lld\n", ans % MOD);
  }
  return 0;
}
