#include <bits/stdc++.h>
using namespace std;
int a[210];
int dp[405][205];
int n;
int ans = 0x3f3f3f3f;
int main() {
  int t;
  cin >> t;
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    memset(dp, 0x3f, sizeof dp);
    for (int i = 1; i <= n; i++) dp[i][1] = abs(i - a[1]);
    for (int i = 1; i <= n * 2; i++) {
      for (int k = 1; k <= n; k++) {
        dp[i][k] = min(dp[i][k], dp[i - 1][k]);
        dp[i][k] = min(dp[i][k], dp[i - 1][k - 1] + abs(i - a[k]));
      }
    }
    ans = 0x3f3f3f3f;
    for (int i = 1; i <= n * 2; i++) {
      ans = min(ans, dp[i][n]);
    }
    cout << ans << endl;
  }
}
