#include <bits/stdc++.h>
using namespace std;
int cnt = 0;
vector<int> cand;
int prime[1000005];
void SieveOfEratosthenes(int n) {
  memset(prime, 0, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == 0) {
      for (int i = p * p; i <= n; i += p) prime[i] = p;
    }
  }
}
int prob = 0;
void dfs(vector<int> adj[], int v, bool visited[], stack<int>& s,
         bool visited2[]) {
  visited[v] = true;
  int i;
  int c = 1;
  bool f = true;
  for (i = 0; i < adj[v].size(); i++) {
    if (!visited[adj[v][i]]) {
      f = false;
      dfs(adj, adj[v][i], visited, s, visited2);
    }
  }
  if (adj[v].size() == 1) {
    s.push(v);
    visited2[v] = true;
  }
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x % 1000000007;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
long long add(long long x, long long y) {
  x += y;
  while (x >= 1000000007) x -= 1000000007;
  while (x < 0) x += 1000000007;
  return x;
}
long long mul(long long x, long long y) { return (x * 1ll * y) % 1000000007; }
long long binpow(long long x, long long y) {
  long long z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
long long inv(long long x) { return binpow(x, 1000000007 - 2); }
long long divide(long long x, long long y) { return mul(x, inv(y)); }
long long fact[1000001];
void precalc() {
  fact[0] = 1;
  for (long long i = 1; i < 1000001; i++) fact[i] = mul(fact[i - 1], i);
}
long long C(long long n, long long k) {
  if (n == 0) return 1;
  return divide(fact[n], mul(fact[k], fact[n - k]));
}
int dfs(bool visited[], vector<int> adj[], int v) {
  int c = 1;
  visited[v] = true;
  for (int i = 0; i < adj[v].size(); i++) {
    if (!visited[adj[v][i]]) {
      c += dfs(visited, adj, adj[v][i]);
    }
  }
  return c;
}
struct comp {
  bool operator()(const pair<int, int>& p1, const pair<int, int>& p2) {
    if (p1.first == p2.first) {
      return p1.second < p2.second;
    } else
      return p1.first > p2.first;
  }
};
long long sub(long long A, long long B) {
  return (A - B + 1000000007) % 1000000007;
}
void toposort(vector<int>& order, int v, int visited[], vector<int> adj[]) {
  visited[v] = 1;
  int i;
  for (i = 0; i < adj[v].size(); i++) {
    if (!visited[adj[v][i]]) {
      toposort(order, adj[v][i], visited, adj);
    }
  }
  order.push_back(v);
}
long long segtree[4 * 200010 + 1];
int build(long long A[], long long tl, long long tr, long long v) {
  if (tl == tr) {
    segtree[v] = A[tl - 1];
    return 1;
  } else {
    long long tm = (tl + tr) / 2;
    int x = build(A, tl, tm, v * 2);
    x = build(A, tm + 1, tr, 2 * v + 1);
    if (x % 2 == 1)
      segtree[v] = (segtree[2 * v] | segtree[2 * v + 1]);
    else
      segtree[v] = (segtree[2 * v] ^ segtree[2 * v + 1]);
    return x + 1;
  }
}
long long maxival(long long v, long long tl, long long tr, long long l,
                  long long r) {
  if (l > r) return LLONG_MAX;
  if (l == tl && r == tr) return segtree[v];
  long long tm = (tl + tr) / 2;
  return min(maxival(2 * v, tl, tm, l, min(r, tm)),
             maxival(2 * v + 1, tm + 1, tr, max(l, tm + 1), r));
}
int updateval(long long v, long long tl, long long tr, long long pos,
              long long newval) {
  if (tl == tr) {
    segtree[v] = newval;
    return 1;
  } else {
    long long tm = (tl + tr) / 2;
    int x;
    if (pos <= tm)
      x = updateval(2 * v, tl, tm, pos, newval);
    else
      x = updateval(2 * v + 1, tm + 1, tr, pos, newval);
    if (x % 2 == 1)
      segtree[v] = (segtree[2 * v] | segtree[2 * v + 1]);
    else
      segtree[v] = (segtree[2 * v] ^ segtree[2 * v + 1]);
    return x + 1;
  }
}
long long dp[302][1002];
int recur(int n, int i, int time, int A[]) {
  if (i == n) return 0;
  if (time == 1001) return 4000000;
  if (dp[i][time] != -1) return dp[i][time];
  dp[i][time] = 0;
  dp[i][time] = min(abs(time - A[i]) + recur(n, i + 1, time + 1, A),
                    recur(n, i, time + 1, A));
  return dp[i][time];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(5);
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int A[n];
    int i;
    for (i = 0; i < n; i++) cin >> A[i];
    sort(A, A + n);
    memset(dp, -1, sizeof(dp));
    cout << recur(n, 0, 1, A) << "\n";
  }
  return 0;
}
