#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int A, long long int M) {
  return power(A, M - 2, M);
}
int phi(int n) {
  float result = n;
  for (int p = 2; p * p <= n; ++p) {
    if (n % p == 0) {
      while (n % p == 0) n /= p;
      result *= (1.0 - (1.0 / (float)p));
    }
  }
  if (n > 1) result *= (1.0 - (1.0 / (float)n));
  return (int)result;
}
void openFiles() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void swap(int* a, int* b) {
  int t = *a;
  *a = *b;
  *b = t;
}
int prime_factor[100000];
vector<pair<int, int> > prime_factors[100000];
void GeneratePrimeFactors(int N) {
  for (int i = 2; i < N; i++) {
    if (prime_factor[i] != 0) continue;
    prime_factor[i] = i;
    for (int j = 2 * i; j < N; j += i) {
      prime_factor[j] = i;
    }
  }
  for (int i = 2; i < N; i++) {
    int x = i;
    map<int, int> M;
    while (x != 1) {
      M[prime_factor[x]]++;
      x /= prime_factor[x];
    }
    for (auto v : M) {
      prime_factors[i].push_back(v);
    }
  }
}
bool prime[1000007];
void Seive(int N) {
  memset(prime, true, sizeof(prime));
  for (int i = 2; i <= N; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j <= N; j += i) prime[j] = false;
    }
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int t[n + 1];
    for (int i = 1; i <= n; i++) cin >> t[i];
    sort(t + 1, t + n + 1);
    int dp[n + 1][2 * n + 1];
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= 2 * n; j++) {
        dp[i][j] = 1e7;
      }
    }
    for (int j = 1; j <= 2 * n; j++) {
      dp[0][j] = 0;
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= 2 * n; j++) {
        for (int k = 0; k < j; k++)
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + abs(t[i] - j));
      }
    }
    int mn = INT_MAX;
    for (int j = 0; j <= 2 * n; j++) {
      mn = min(mn, dp[n][j]);
    }
    cout << mn << endl;
  }
  return 0;
}
