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