#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int N = 100311;
int binpow(int x, int y) {
  if (y == 0) return 1;
  if (y == 1)
    return x % mod;
  else if (y % 2 == 0) {
    int w = binpow(x, y / 2) % mod;
    return (w * w) % mod;
  } else
    return ((x % mod) * (binpow(x, y - 1) % mod)) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 17];
    int sum = 0;
    for (int i = 0; i < n; i++) cin >> a[i], a[i]--;
    sort(a, a + n);
    vector<vector<int>> dp(n + 1, vector<int>(2 * n, 1e9));
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++)
      for (int t = 0; t < 2 * n - 1; t++) {
        if (dp[i][t] < 1e9) {
          if (i < n)
            dp[i + 1][t + 1] = min(dp[i + 1][t + 1], dp[i][t] + abs(a[i] - t));
          dp[i][t + 1] = min(dp[i][t + 1], dp[i][t]);
        }
      }
    cout << dp[n][2 * n - 1] << "\n";
  }
}
