#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e2 + 10;
int q, t[maxn], dp[maxn][maxn], n, ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      for (int i2 = 0; i2 < maxn; i2++) dp[i][i2] = maxn * maxn;
    }
    for (int i = 0; i < n; i++) cin >> t[i];
    sort(t, t + n);
    for (int i = 1; i < maxn; i++) dp[0][i] = abs(t[0] - i);
    for (int i = 1; i < n; i++) {
      for (int i2 = i + 1; i2 < maxn; i2++) {
        for (int i3 = 1; i3 < i2; i3++)
          dp[i][i2] = min(dp[i][i2], dp[i - 1][i3] + abs(t[i] - i2));
      }
    }
    ans = dp[n - 1][0];
    for (int i = n; i < maxn; i++) ans = min(ans, dp[n - 1][i]);
    cout << ans << endl;
  }
  return 0;
}
