#include <bits/stdc++.h>   using namespace std;   template <typename... T>   void read(T &...args) {     ((cin >> args), ...);   }   template <typename... T>   void write(T... args) {     ((cout << args <<    ), ...);   }   const long long MOD = 1000000007;   const long long INF = 1000000050;   const long long BIG = (long long)2e18 + 50;   const long long MX = 200010;   const double EPS = 1e-9;   long long a[MX];   bool good;   long long m;   vector<long long> g[MX];   long long sz[MX];   long long cnt[MX];   long long mx = 0;   void dfs(long long v) {     if (g[v].size() == 0)       cnt[v] = 1;     else       cnt[v] = 0;     sz[v] = a[v];     for (auto &to : g[v]) {       dfs(to);       cnt[v] += cnt[to];       sz[v] += sz[to];     }     mx = max(mx, (sz[v] + cnt[v] - 1) / cnt[v]);   }   void solve() {     long long n;     cin >> n;     long long arr[n];     for (long long i = 0; i < n; i++) cin >> arr[i];     if (n == 1) {       cout << 0 <<   n ;       return;     }     sort(arr, arr + n);     long long mid = n / 2;     long long ret1 = 0;     long long ret2 = 0;     long long arr_val[n];     for (long long i = 0; i < n; i++) {       arr_val[i] = arr[mid] - mid + i;     }     if (arr_val[0] <= 0) {       long long val = 1 - arr_val[0];       for (long long i = 0; i < n; i++) arr_val[i] += val;     }     for (long long i = 0; i < n; i++) {       ret1 += abs(arr_val[i] - arr[i]);     }     write(  n );     for (long long i = 0; i < n; i++) write(arr_val[i]);     if (n % 2 == 0) {       mid--;       for (long long i = 0; i < n; i++) {         arr_val[i] = arr[mid] - mid + i;       }       if (arr_val[0] <= 0) {         long long val = 1 - arr_val[0];         for (long long i = 0; i < n; i++) arr_val[i] += val;       }       for (long long i = 0; i < n; i++) {         ret2 += abs(arr_val[i] - arr[i]);       }     }     write(  n );     for (long long i = 0; i < n; i++) write(arr_val[i]);     if (n % 2 == 0)       cout << min(ret1, ret2);     else       cout << ret1;     cout <<   n ;   }   long long arr[201];   long long dp[201][405];   long long n;   long long recur(long long index, long long time) {     if (index == n) return 0;     if (dp[index][time] != -1) return dp[index][time];     long long ret = INT_MAX;     for (long long i = time + 1; i <= 405; i++) {       ret = min(ret, abs(arr[index] - i) + recur(index + 1, i));     }     return dp[index][time] = ret;   }   void solveA() {     cin >> n;     memset(dp, -1, sizeof(dp));     for (long long i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     cout << recur(0, 0) <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     srand(chrono::high_resolution_clock::now().time_since_epoch().count());     long long x;     cin >> x;     while (x--) {       solveA();     }   }   