#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long N = 1e3 + 7;
const long long mod = 1e9 + 7;
long long a[N], dp[N][N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      for (long long j = 0; j <= 2 * n; j++) {
        dp[i][j] = mod;
      }
    }
    for (long long i = 0; i <= 2 * n; i++) {
      dp[n + 1][i] = mod;
    }
    sort(a + 1, a + 1 + n);
    dp[1][1] = 0;
    for (long long i = 1; i <= n + 1; i++) {
      for (long long j = 1; j <= 2 * n; j++) {
        if (dp[i][j] < mod) {
          if (i <= n) {
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + abs(a[i] - j));
          }
          dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
        }
      }
    }
    cout << dp[n + 1][2 * n] << '\n';
  }
}
