#include <bits/stdc++.h>
using namespace std;
const int N = 300;
int a[N];
int dp[N][N * 3];
inline void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  memset(dp, 0x3f, sizeof dp);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n * 2; j++) {
      for (int k = i - 1; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i - 1][k] + abs(j - a[i]));
      }
    }
  }
  int res = 1e9;
  for (int i = n; i <= n * 2; i++) res = min(res, dp[n][i]);
  cout << res << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
