#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
const long long maxn = 204;
long long mas[maxn];
long long inf = 1000000000000015;
long long dp[maxn][2 * maxn];
signed main() {
  fast();
  long long t, n, i, j, k;
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 1; i <= n; i++) {
      cin >> mas[i];
    }
    sort(mas + 1, mas + n + 1);
    for (i = 0; i <= n; i++) {
      for (j = 0; j <= 2 * n; j++) {
        dp[i][j] = inf;
      }
    }
    for (j = 0; j <= 2 * n; j++) {
      dp[0][j] = 0;
    }
    for (i = 1; i <= n; i++) {
      for (j = i; j <= 2 * n; j++) {
        for (k = i; k <= j; k++) {
          dp[i][j] = min(dp[i][j], dp[i - 1][k - 1] + abs(mas[i] - k));
        }
      }
    }
    long long ans = inf;
    for (j = 1; j <= 2 * n; j++) {
      ans = min(ans, dp[n][j]);
    }
    cout << ans << endl;
  }
  return 0;
}
