#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll>PII; const int N = 2e5 + 10; const int MOD = 998244353; const int INF = 0X3F3F3F3F; const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1}; const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1}; const int M = 1e9 + 7; ll a[N]; int main() { int t; cin >> t; while(t --){ int n, l, r; cin >> n >> l >> r; ll s1 = 0, s2 = 0, s = 0; for(int i = 1; i <= n; i ++) { cin >> a[i]; s += a[i]; if(a[i] < l) s1 += l - a[i]; if(a[i] > r) s2 += a[i] - r; } if((s / n == r && s % n == 0) || (s / n >= l && s / n < r)) cout << max(s1, s2) << endl; else cout << -1 << endl; } return 0; }