#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n, a;
		long long M;
		cin >> n >> a >> M;
		vector<long long> arr(n);
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}
		long long L = 0, R = (long long)1e18;
		while (L + 1 < R) {
			long long mid = (L + R) / 2;
			__int128 ost = M;
			for (auto el: arr) {
				if (el < mid) {
					// double t = (-1 + sqrt(1 + 2 * a * el));
					// ost -= (t + 1) * (t + 1);

					ost -= (1 + (__int128)2LL * a * el);
				} else {
					//double
					// a t^2/2 + t = mid

					// a * t^2 + 2t - mid = 0

					// double t = (-1 + sqrt(1 + 2 * a * mid));
					// // (v + 1)^2 = (at + 1)^2 = a^2t^2 + 2at + 1
					// ost -= (t + 1) * (t + 1);

					ost -= (1 + (__int128)2LL * a * mid);
				}
			}
			if (ost <= 0) {
				R = mid;
			} else {
				L = mid;
			}
		}
		cout << L << endl;
	}
}