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