#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t;
  cin >> t;
  while (t > 0) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
      cin >> v[i];
    }
    sort(v.begin(), v.end());
    vector<vector<int>> dp(n + 1, vector<int>(2 * n + 1, INT_MAX));
    dp[0][1] = 0;
    for (int i = 0; i <= n; ++i) {
      for (int T = 1; T < 2 * n; ++T) {
        if (dp[i][T] < INT_MAX) {
          if (i < n)
            dp[i + 1][T + 1] = min(dp[i + 1][T + 1], dp[i][T] + abs(T - v[i]));
          dp[i][T + 1] = min(dp[i][T + 1], dp[i][T]);
        }
      }
    }
    cout << dp[n][2 * n] << endl;
    t--;
  }
  return 0;
}
