#include <bits/stdc++.h>
const int mod = 1000000007;
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int prime[100007];
void SieveOfEratosthenes(int n) {
  memset(prime, -1, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == -1) {
      for (int i = p * p; i <= n; i += p) prime[i] = p;
    }
  }
}
int lps(string s) {
  int len = 0;
  int n = s.length();
  int dp[n];
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[len]) {
      len++;
      dp[i] = len;
      continue;
    }
    if (len != 0) {
      len = dp[len - 1];
      i--;
      continue;
    }
    dp[i] = 0;
  }
  return dp[n - 1];
}
long long power(unsigned long long x, unsigned long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
vector<pair<long long, long long>> pFactor;
void factorize(long long n) {
  int count = 0;
  while (!(n % 2)) {
    n >>= 1;
    count++;
  }
  if (count) pFactor.push_back({2, count});
  for (long long i = 3; i <= sqrt(n); i += 2) {
    count = 0;
    while (n % i == 0) {
      count++;
      n = n / i;
    }
    if (count) pFactor.push_back({i, count});
  }
  if (n > 2) pFactor.push_back({n, 1});
}
int dp[405][405];
int solve(int a[], int n, int i, int t) {
  if (i > n) {
    return 0;
  }
  if (t > 2 * n) {
    return INT_MAX;
  }
  if (dp[i][t] != -1) {
    return dp[i][t];
  }
  int x = solve(a, n, i + 1, t + 1);
  if (x != INT_MAX) {
    x += abs(t - a[i]);
  }
  x = min(x, solve(a, n, i, t + 1));
  dp[i][t] = x;
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 1];
    for (long long i = 1; i < n + 1; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    memset(dp, -1, sizeof(dp));
    int x = solve(a, n, 1, 1);
    cout << x << endl;
  }
}
