#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
      b--;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> v(n);
    for (long long int i = 0; i < n; i++) cin >> v[i];
    sort((v).begin(), (v).end());
    long long int dp[n][450];
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < 450; j++) dp[i][j] = 1e17;
    }
    for (long long int j = 1; j < 450; j++) {
      dp[0][j] = abs(v[0] - j);
      dp[0][j] = min(dp[0][j], dp[0][j - 1]);
    }
    for (long long int i = 1; i < n; i++) {
      for (long long int j = i + 1; j < 450; j++) {
        dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + abs(v[i] - j));
      }
      for (long long int j = 2; j < 450; j++)
        dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
    long long int ans = 1e17;
    for (long long int j = 1; j < 450; j++) ans = min(ans, dp[n - 1][j]);
    cout << ans << "\n";
  }
}
