#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 1024;
const int MD = 1e9 + 7;
int n, m, k;
int a, b, r;
vector<int> g[N];
vector<int> v;
int dp[M][M];
int cal(int idx, int last) {
  int &ans = dp[idx][last];
  if (ans != -1) return ans;
  if (idx == n) return 0;
  ans = 1e9;
  for (int i = last + 1; i < 2 * n; i++) {
    ans = min(ans, cal(idx + 1, i) + abs(v[idx] - i));
  }
  return ans;
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    v.resize(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    memset(dp, -1, sizeof dp);
    printf("%d\n", cal(0, 0));
  }
  return 0;
}
