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