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