#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 5;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 3000;
inline char nc() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline void read(int &sum) {
  char ch = nc();
  sum = 0;
  while (!(ch >= '0' && ch <= '9')) ch = nc();
  while (ch >= '0' && ch <= '9')
    sum = (sum << 3) + (sum << 1) + (ch - 48), ch = nc();
}
int n;
int a[205];
int dp[405];
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      dp[i] = 1e9;
    }
    sort(a + 1, a + n + 1);
    dp[0] = 0;
    for (int i = 1; i <= 2 * n; i++) {
      for (int j = n; j >= 1; j--) {
        dp[j] = min(dp[j], dp[j - 1] + abs(a[j] - i));
      }
    }
    cout << dp[n] << endl;
  }
  return 0;
}
