#include <bits/stdc++.h>
using namespace std;
void readtxt() {}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
long long int solve(vector<vector<long long int>> &dp, long long int idx,
                    long long int t, long long int n, vector<long long int> a) {
  if (idx == n) return 0;
  if (t == 2 * n + 1) return 1e7;
  if (dp[idx][t] != -1) return dp[idx][t];
  long long int ans = INT_MAX;
  ans = min(ans, solve(dp, idx, t + 1, n, a));
  ans = min(ans, abs(t - a[idx]) + solve(dp, idx + 1, t + 1, n, a));
  return dp[idx][t] = ans;
}
int32_t main() {
  readtxt();
  fast();
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    for (long long int i = 0; i < n; i++) cin >> a[i];
    vector<vector<long long int>> dp(n, vector<long long int>(2 * n + 1, -1));
    sort(a.begin(), a.end());
    cout << solve(dp, 0, 1, n, a) << endl;
  }
}
