#include <bits/stdc++.h>
const int MAXN = 1e3 + 10;
using namespace std;
int minn(int x, int y, int z) {
  if (x <= y && x <= z) return x;
  if (y <= x && y <= z) return y;
  if (z <= x && z <= y) return z;
}
int n;
int a[MAXN], dp[MAXN][MAXN];
int main() {
  int t;
  cin >> t;
  while (t--) {
    memset(dp, 0x3f3f3f3f, sizeof dp);
    dp[0][0] = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= 2 * n; i++) {
      dp[i][0] = 0;
      for (int j = 1; j <= n; j++) {
        dp[i][j] =
            minn(dp[i][j], dp[i - 1][j], dp[i - 1][j - 1] + abs(i - a[j]));
      }
    }
    printf("%d\n", dp[2 * n][n]);
  }
  return 0;
}
