#include <bits/stdc++.h>
using namespace std;
const int N = 410;
int t, n, a[N], f[N][N];
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        f[i][j] = 0x3f3f3f3f;
      }
    }
    sort(a + 1, a + n + 1);
    f[0][0] = 0;
    for (int i = 1; i <= 2 * n; i++) {
      f[i][0] = 0;
      for (int j = n; j >= 1; j--) {
        f[i][j] = min(f[i - 1][j], f[i - 1][j - 1] + abs(a[j] - i));
      }
    }
    int minn = 0x3f3f3f3f;
    for (int i = 1; i <= 2 * n; i++) {
      minn = min(minn, f[i][n]);
    }
    cout << minn << endl;
  }
  return 0;
}
