#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1};
int kx8[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky8[] = {2, -2, 1, -1, 2, -2, 1, -1};
int n, a[100005];
long long dp[500][500];
long long dpcall(int id, int tm) {
  if (id == n) {
    return 0;
  }
  if (tm > 2 * n) return 2134567891;
  long long &ret = dp[id][tm];
  if (~ret) return ret;
  ret = dpcall(id, tm + 1);
  ret = min(ret, abs(tm - a[id]) + dpcall(id + 1, tm + 1));
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    memset((dp), -1, sizeof(dp));
    cin >> n;
    for (int i = 0; i < (n); i++) cin >> a[i];
    sort(a, a + n);
    cout << dpcall(0, 1) << endl;
  }
  return 0;
}
