#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;
template <typename T>
T bpow(T x, size_t n) {
  return n ? n % 2 ? x * bpow(x, n - 1) : bpow(x * x, n / 2) : T(1);
}
template <typename T>
T bpow(T x, size_t n, T m) {
  return n ? n % 2 ? x * bpow(x, n - 1, m) % m : bpow(x * x % m, n / 2, m)
           : T(1);
}
template <ll mod>
class modulo {
 public:
  ll val;
  static ll m, k;
  static bool singleton;
  static void init() {
    if (singleton) return;
    singleton = true;
    int sz = 0;
    while ((1LL << sz) <= mod) ++sz;
    k = sz;
    m = (1LL << (2 * k)) / mod;
  }
  ll Mod(const ll x) const {
    ll t = x - ((x * m) >> (2 * k)) * mod;
    if (t >= mod) t -= mod;
    return t;
  }
  modulo() : val(0) {}
  modulo(ll _val) : val(_val) {
    if (abs(val) >= mod) val = val % mod;
    if (val < 0) val += mod;
  }
  modulo inv() const { return bpow(*this, mod - 2); }
  modulo operator*(const modulo &rhs) const { return (val * rhs.val) % mod; }
  modulo operator/(const modulo &rhs) const { return *this * rhs.inv(); }
  modulo operator+=(const modulo &rhs) {
    val += rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  modulo operator-=(const modulo &rhs) {
    val -= rhs.val;
    if (val < 0) val += mod;
    return *this;
  }
  modulo operator+(const modulo &rhs) const { return modulo(*this) += rhs; }
  modulo operator-(const modulo &rhs) const { return modulo(*this) -= rhs; }
  modulo operator*=(const modulo &rhs) { return *this = *this * rhs; }
  modulo operator/=(const modulo &rhs) { return *this = *this / rhs; }
  bool operator==(const modulo &rhs) const { return val == rhs.val; }
  bool operator!=(const modulo &rhs) const { return val != rhs.val; }
  operator int64_t() const { return val; }
};
template <ll mod>
bool modulo<mod>::singleton = false;
template <ll mod>
ll modulo<mod>::m = 0;
template <ll mod>
ll modulo<mod>::k = 0;
modulo<mod> one = 1;
int N, M;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  vector<ll> arr(N + 1);
  arr[0] = 0;
  vector<modulo<mod>> sum(N + 1);
  sum[0] = 0;
  for (int i = 1; i <= N; ++i) cin >> arr[i];
  sort(arr.begin(), arr.end());
  for (int i = 1; i <= N; ++i) sum[i] = sum[i - 1] + modulo<mod>(arr[i]);
  for (int i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    auto idx = lower_bound(arr.begin(), arr.end(), b) - arr.begin();
    modulo<mod> weak = idx - 1, strong = N - idx + 1;
    if (a > strong || a == N) {
      cout << 0 << '\n';
      continue;
    }
    modulo<mod> strong_sum = sum[N] - sum[idx - 1], weak_sum = sum[idx - 1];
    modulo<mod> s_damage = strong_sum * (strong - modulo<mod>(a)) / strong,
                w_damage =
                    weak_sum * (strong - modulo<mod>(a) + one) / (strong + one);
    cout << s_damage + w_damage << '\n';
  }
  return 0;
}
