#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e5 + 100;
const int maxn = 1e6;
const int MAXL = sqrt(1e7) + 1;
int n, a[220], f[220][410];
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 400; j++) f[i][j] = INT_MAX;
  }
  for (int j = 1; j <= 400; j++) {
    f[1][j] = abs(j - a[1]);
    f[1][j] = min(f[1][j], f[1][j - 1]);
  }
  for (int i = 2; i <= n; i++) {
    for (int j = i; j <= 400; j++) {
      f[i][j] = min(f[i][j], f[i - 1][j - 1] + abs(j - a[i]));
      f[i][j] = min(f[i][j], f[i][j - 1]);
    }
  }
  int ans = INT_MAX;
  for (int i = n; i <= 400; i++) ans = min(ans, f[n][i]);
  printf("%d\n", ans);
}
int main() {
  int T;
  scanf("%d", &T);
  int tt = 0;
  while (T--) {
    solve();
  }
  return 0;
}
