#include <bits/stdc++.h>
using namespace std;
const long long I1 = 1e9;
const long long I2 = 1e18;
const int32_t M1 = 1e9 + 7;
const int32_t M2 = 998244353;
template <typename T, typename T1>
T maxn(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T minn(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
void solve() {
  int n;
  cin >> n;
  int dp[n + 1][405];
  for (long long int i = 0; i < n + 1; i++) {
    for (long long int j = 0; j < 402; j++) {
      dp[i][j] = I1;
    }
  }
  int a[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (long long int i = 1; i <= n; i++) {
    for (int j = 1; j <= 400; j++) {
      if (j < i) continue;
      dp[i][j] = dp[i][j - 1];
      int val = (dp[i - 1][j - 1] < I1 ? dp[i - 1][j - 1] : 0) + abs(a[i] - j);
      minn(dp[i][j], val);
    }
  }
  cout << dp[n][400] << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int testcase = 1;
  cin >> testcase;
  while (testcase--) solve();
  return 0;
}
