#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  cin >> T;
  for (int t = 1; t <= T; t++) {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    const int inf = 1e9;
    vector<vector<int>> dp(n + 1, vector<int>(2 * n + 1, inf));
    int ans = inf;
    for (int p = 0; p <= 2 * n; p++) dp[0][p] = 0;
    for (int i = 1; i <= n; i++) {
      for (int p = 0; p <= 2 * n; p++) {
        for (int m = p + 1; m <= 2 * n; m++) {
          dp[i][m] = min(dp[i][m], (dp[i - 1][p] + abs(a[i] - m)));
        }
      }
    }
    for (int p = 1; p <= 2 * n; p++) ans = min(ans, dp[n][p]);
    cout << ans;
    cout << "\n";
  }
  return 0;
}
