#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
int p[N];
int dp[N][2 * N];
int main() {
  int T;
  cin >> T;
  while (T--) {
    memset(dp, 0x3f, sizeof dp);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> p[i];
    sort(p + 1, p + n + 1);
    for (int i = 1; i <= n; i++) dp[1][i] = abs(p[1] - i);
    for (int i = 2; i <= n; i++) {
      for (int j = 1; j <= 2 * n; j++) {
        for (int k = i - 1; k < j; k++) {
          dp[i][j] = min(dp[i - 1][k], dp[i][j]);
        }
        dp[i][j] += abs(p[i] - j);
      }
    }
    int ans = 0x3f3f3f3f;
    for (int j = 1; j <= 2 * n; j++) ans = min(ans, dp[n][j]);
    cout << ans << endl;
  }
  return 0;
}
