#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const double eps = 0;
const int ms = 0;
const int md = 0;
const int mod = 1e9 + 7;
int n;
vector<int> a;
vector<vector<long long> > asdsfdas;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  ;
  while (t--) {
    int n;
    cin >> n;
    ;
    a.resize(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    asdsfdas = vector<vector<long long> >(n + 1, vector<long long>(301, 0));
    sort((a).begin(), (a).end());
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= i - 1; j++) asdsfdas[i][j] = inf;
      for (int j = i; j <= 300; j++) {
        asdsfdas[i][j] =
            min(asdsfdas[i][j - 1], asdsfdas[i - 1][j - 1] + abs(j - a[i]));
      }
    }
    cout << asdsfdas[n][300] << '\n';
  }
  return 0;
}
