#include <bits/stdc++.h>
using namespace std;
int d4x[] = {0, 0, 1, -1};
int d4y[] = {1, -1, 0, 0};
int d8x[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int d8y[] = {-1, 0, 1, -1, 1, -1, 0, 1};
long long a[205];
long long n;
long long dp[205][305];
long long f(int i, int k) {
  if (i == n) return 0;
  if (dp[i][k] != -1) return dp[i][k];
  long long res = 696969;
  for (int kk = k + 1; kk <= 301; kk++) {
    res = min(res, abs(kk - a[i]) + f(i + 1, kk));
  }
  return dp[i][k] = res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    memset(dp, -1, sizeof(dp));
    ;
    cout << f(0, 0) << "\n";
  }
  return 0;
}
