#include <bits/stdc++.h>
using namespace std;
void solve() {}
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int& a : v) cin >> a;
    sort(v.begin(), v.end());
    vector<vector<int> > dp(n + 1, vector<int>(2 * n, 1e9));
    dp[0] = vector<int>(2 * n, 0);
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < 2 * n; j++)
        dp[i + 1][j] = min(dp[i + 1][j - 1], dp[i][j - 1] + abs(v[i] - j));
    }
    cout << dp[n][n * 2 - 1] << "\n";
  }
  return 0;
}
