#include <bits/stdc++.h>
using namespace std;
int t;
void solve() {
  cin >> t;
  int n;
  int v[202];
  int inf = pow(10, 5);
  vector<vector<int>> dp(202, vector<int>(403, inf));
  for (int _i = 0; _i < t; _i++) {
    cin >> n;
    for (int j = 1; j <= n; j++) {
      cin >> v[j];
    }
    sort(v + 1, v + n + 1, less<int>());
    for (int j = 0; j <= 2 * n; j++) dp[0][j] = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= 2 * n; j++) {
        dp[i][j] = min(dp[i - 1][j - 1] + abs(v[i] - j), dp[i][j - 1]);
      }
    cout << dp[n][2 * n] << "\n";
  }
  return;
}
int main() {
  ;
  solve();
  ;
  return 0;
}
