#include <bits/stdc++.h>
using namespace std;
const int N = 210, M = 310;
int a[N], dp[N][M], n;
int DP(int i, int lav) {
  if (i > n) return 0;
  if (dp[i][lav] != -1) return dp[i][lav];
  if (lav > 300) return 1e9;
  return dp[i][lav] = min(DP(i + 1, lav + 1) + abs(a[i] - lav), DP(i, lav + 1));
}
int main() {
  int _;
  cin >> _;
  while (_--) {
    memset(dp, -1, sizeof dp);
    int i;
    cin >> n;
    for (i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    cout << DP(1, 1) << endl;
  }
  return 0;
}
