#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool compare(const pair<string, int> &a, const pair<string, int> &b) {
  return a.second < b.second;
}
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i], a[i]--;
  sort(a.begin(), a.end());
  vector<vector<int> > dp(n + 1, vector<int>(2 * n, 1e9));
  dp[0][0] = 0;
  for (int i = 0; i <= n; i++) {
    for (int t = 0; t < 2 * n - 1; t++) {
      if (dp[i][t] < 1e9) {
        if (i < n)
          dp[i + 1][t + 1] = min(dp[i][t] + abs(a[i] - t), dp[i + 1][t + 1]);
        dp[i][t + 1] = min(dp[i][t + 1], dp[i][t]);
      }
    }
  }
  cout << dp[n][2 * n - 1] << "\n";
}
int main() {
  int t = 1, k = 1;
  cin >> t;
  while (t--) {
    solve();
    k++;
  }
}
