#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
int main()
{
    int T, n;
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
            scanf("%lld", a + i);
        sort(a, a + n);
        ll sum = 0;
        for (int i = 0; i < n; i++)
            sum += a[n - 1] - a[i];
        if (a[n - 1] - sum < 1) sum = -1;
        printf("%lld\n", sum);
    }
    return 0;
}
