#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <deque>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#include <fstream>
#include <ctime>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vec vector
#define pb push_back

const int INF = 1e9;

void solve() {
    int n, a, m;
    cin >> n >> a >> m;
    vec<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    sort(all(x));
    vec<int> pref(n + 1);
    for (int i = 0; i < n; ++i) {
        pref[i + 1] = pref[i] + x[i];
    }
    if (m <= n) {
        cout << 0 << "\n";
        return;
    }
    int limit = (m - n - 1) / (2 * a);
    int l = 1, r = 2e18;
    int ans = 1;
    while (l <= r) {
        int mid = (l + r) / 2;
        __int128 idx = lower_bound(all(x), mid) - x.begin();
        __int128 current_sum = pref[idx];
        current_sum += (__int128)(n - idx) * mid;
        if (current_sum <= (__int128)limit) {
            ans = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(time(0));
    int t = 1; cin >> t;
    for (; t > 0; --t) {
        solve();
    }
}