#include <bits/stdc++.h>
using namespace std;
int MAXN = 401;
int main() {
  int T;
  cin >> T;
  for (int l = 0; l < T; l++) {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];
    sort(vec.begin(), vec.end());
    vector<vector<int>> dp(n + 1, vector<int>(MAXN, (int)1e9));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      int val = vec[i - 1];
      int preMin = 1e9;
      for (int j = i; j < MAXN; j++) {
        preMin = min(preMin, dp[i - 1][j - 1]);
        dp[i][j] = preMin + abs(val - j);
      }
    }
    int ret = 1e9;
    for (int i = n; i < dp[n].size(); i++) {
      ret = min(ret, dp[n][i]);
    }
    cout << ret << endl;
  }
}
