#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long n) {
  long long p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
long long power(long long a, long long n, long long mod) {
  long long p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
      p %= mod;
    }
    n >>= 1;
    a *= a;
    a %= mod;
  }
  return p % mod;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
void out(vector<long long> arr) {
  for (auto i : arr) {
    cout << i << ' ';
  }
  cout << "\n";
}
void out(vector<pair<long long, long long>> par) {
  for (auto i : par) {
    cout << i.first << ' ';
  }
  cout << endl;
  for (auto i : par) {
    cout << i.second << ' ';
  }
  cout << endl;
}
void out(set<long long> arr) {
  for (auto i : arr) {
    cout << i << ' ';
  }
  cout << endl;
}
void inp(vector<long long> &arr) {
  for (long long i = 0; i < arr.size(); i++) {
    cin >> arr[i];
  }
}
void inp(long long &n) { cin >> n; }
void inp(long long &a, long long &b, long long &c) { cin >> a >> b >> c; }
void inp(long long &a, long long &b) { cin >> a >> b; }
void inp(long long &a, long long &b, long long &c, long long &d) {
  cin >> a >> b >> c >> d;
}
long long MOD = 1e9 + 7;
const long long N = 2e5 + 10;
;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> arr(n);
    for (long long i = 0; i < n; i++) cin >> arr[i];
    sort(arr.begin(), arr.end());
    long long T = 400;
    vector<vector<long long>> dp(T + 5, vector<long long>(n + 1, INT_MAX));
    dp[0][0] = 0;
    for (long long i = 0; i < T; i++) {
      dp[i][0] = 0;
    }
    for (long long i = 1; i < n + 1; i++) {
      for (long long j = 1; j < T; j++) {
        dp[j][i] = min(dp[j][i], dp[j - 1][i]);
        dp[j][i] = min(dp[j][i], dp[j - 1][i - 1] + abs(j - arr[i - 1]));
      }
    }
    long long ans = INT_MAX;
    for (long long i = 0; i < T; i++) {
      ans = min(ans, dp[i][n]);
    }
    cout << ans << "\n";
  }
}
