#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long hell = round(1e18);
signed solve() {
  long long n;
  cin >> n;
  vector<long long> v(n + 1);
  for (long long i = 1; i <= n; i++) cin >> v[i];
  sort((v).begin(), (v).end());
  vector<vector<long long>> dp(2 * n + 1, vector<long long>(n + 1, hell));
  dp[0][0] = 0;
  for (long long t = 1; t <= 2 * n; t++) {
    dp[t][0] = 0;
    for (long long i = 1; i <= min(t, n); i++) {
      dp[t][i] = min(dp[t - 1][i], dp[t - 1][i - 1] + abs(t - v[i]));
    }
  }
  cout << dp[2 * n][n] << endl;
  return 0;
}
signed main() {
  long long t = 1;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
