#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lint = long long;
const lint inf = 1e9 + 7;
const int MOD = 1000000007;
void solve() {
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n; ++i) cin >> t[i];
  t.push_back(-1);
  sort(t.begin(), t.end());
  vector<vector<int>> dp(n * 2 + 1, vector<int>(n + 1, inf));
  dp[0][0] = 0;
  for (int i = 1; i <= 2 * n; ++i) {
    for (int j = 0; j < n + 1; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (j == 0) continue;
      dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + abs(i - t[j]));
    }
  }
  lint res = dp[n * 2][n];
  cout << res << "\n";
}
signed main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) solve();
  return 0;
}
