#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int ran(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
using ulli = unsigned long long;
using lli = long long;
using ld = long double;
using ii = pair<int, int>;
using vi = vector<int>;
const int N = 405;
int n, a[N], dp[N][N];
template <class T>
void umin(T &a, T b) {
  a = min(a, b);
}
void solve() {
  cin >> n;
  for (auto i = (1) - ((1) > (n + 1)); i != n + 1 - ((1) > (n + 1));
       i += 1 - 2 * ((1) > (n + 1)))
    cin >> a[i];
  sort(a + 1, a + n + 1);
  memset(dp, 0x3f, sizeof dp);
  for (auto time = (0) - ((0) > (N)); time != N - ((0) > (N));
       time += 1 - 2 * ((0) > (N)))
    dp[0][time] = 0;
  for (auto i = (1) - ((1) > (n + 1)); i != n + 1 - ((1) > (n + 1));
       i += 1 - 2 * ((1) > (n + 1)))
    for (auto time = (1) - ((1) > (N)); time != N - ((1) > (N));
         time += 1 - 2 * ((1) > (N))) {
      umin(dp[i][time], dp[i][time - 1]);
      umin(dp[i][time], dp[i - 1][time - 1] + (abs(time - a[i])));
    }
  cout << dp[n][N - 1] << '\n';
}
int main() {
  cin.tie(0)->sync_with_stdio(0), cout.tie(0);
  int tc = 1;
  cin >> tc;
  for (auto i = (1) - ((1) > (tc + 1)); i != tc + 1 - ((1) > (tc + 1));
       i += 1 - 2 * ((1) > (tc + 1)))
    solve();
  return 0;
}
