#include <bits/stdc++.h>
using namespace std;
int A[10000], B[1000][1000], n;
int f(int a, int b) {
  if (B[a][b] > 0) return B[a][b];
  int s;
  if (a > n * 2) return 100000000;
  if (b == n) return 0;
  s = f(a + 1, b);
  s = min(s, f(a + 1, b + 1) + abs(A[b] - a));
  return B[a][b] = s;
}
int main() {
  ios::sync_with_stdio(false);
  int T, i, j;
  cin >> T;
  while (T--) {
    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];
    sort(A, A + n);
    for (i = 0; i <= n * 2; i++) {
      for (j = 0; j < n + 2; j++) B[i][j] = 0;
    }
    cout << f(1, 0) << "\n";
  }
}
