#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e7 + 5;
long long t[205];
long long dp[205][410];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= 2 * n; j++) dp[i][j] = mod;
  for (long long j = 0; j <= 2 * n; j++) dp[0][j] = 0;
  for (long long i = 1; i <= n; i++) cin >> t[i];
  sort(t + 1, t + n + 1);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= 2 * n; j++) {
      dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + abs(j - t[i]));
    }
  }
  long long mi = mod;
  for (long long i = 1; i <= 2 * n; i++) mi = min(mi, dp[n][i]);
  cout << mi << endl;
}
int32_t main() {
  long long z;
  z = 1;
  cin >> z;
  while (z--) {
    solve();
  }
  return 0;
}
