#include <bits/stdc++.h>
using namespace std;
int t1, n, i, j, a[202], f[202][404];
int main() {
  scanf("%d", &t1);
  while (t1--) {
    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    memset(f, 44, sizeof(f));
    for (j = 0; j <= n * 2; j++) f[0][j] = 0;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n * 2; j++) {
        f[i][j] = min(f[i][j - 1], f[i - 1][j - 1] + abs(a[i] - j));
      }
    printf("%d\n", f[n][n * 2]);
  }
}
