#include <bits/stdc++.h>
using namespace std;
int a[205], f[205][405], pf[205][405];
inline int abs(int a) {
  if (a < 0) return -a;
  return a;
}
inline int min(int a, int b) { return a < b ? a : b; }
int main() {
  int T, i, j;
  scanf("%d", &T);
  while (T--) {
    memset(f, 0x3f, sizeof(f));
    memset(pf, 0x3f, sizeof(f));
    int n;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    f[0][0] = 0;
    for (j = 0; j <= n * 2; j++) pf[0][j] = 0;
    for (i = 1; i <= n; i++)
      for (j = i; j <= n * 2; j++) {
        f[i][j] = min(f[i][j], pf[i - 1][j - 1] + abs(a[i] - j));
        pf[i][j] = min(pf[i][j - 1], f[i][j]);
      }
    printf("%d\n", pf[n][2 * n]);
  }
  return 0;
}
