#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const long double PI = acosl(-1.0l);
const long long MAXN = numeric_limits<long long>::max();
const long long MINN = (1e9 + 1);
long long modular_exp(int a, int n) {
  if (n == 0) return 1;
  long long half_ans = modular_exp(a, n / 2);
  if (n % 2 == 0) {
    return (half_ans * half_ans) % MOD;
  } else {
    half_ans = (half_ans * half_ans) % MOD;
    half_ans = (half_ans * a) % MOD;
    return half_ans;
  }
}
long long fact(long long n) {
  long long res = 1;
  for (int i = 1; i <= n; i++) res = (res * i) % MOD;
  return res;
}
long long C(long long n, long long k) {
  return fact(n) * modular_exp(fact(k), MOD - 2) % MOD *
         modular_exp(fact(n - k), MOD - 2) % MOD;
}
void solve() {
  long long n, i, j, k;
  cin >> n;
  vector<long long> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long m = *max_element((a).begin(), (a).end());
  vector<vector<long long> > dp(n, vector<long long>(m + n + 1, INF));
  for (i = 0; i < m + n + 1; i++) {
    dp[0][i] = abs(i - a[0]);
  }
  for (i = 1; i < n; i++) {
    for (j = 1; j < m + n + 1; j++) {
      for (k = 1; k < j; k++) {
        long long val = abs(a[i] - j);
        dp[i][j] = min(dp[i][j], dp[i - 1][k] + val);
      }
    }
  }
  long long ans = *min_element((dp[n - 1]).begin(), (dp[n - 1]).end());
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  int t = 1;
  cin >> t;
  while (t) {
    t--;
    solve();
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
