#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 50;
int dp[405][405], a[205];
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    memset(dp, 0x3f3f3f3f, sizeof(dp));
    dp[0][0] = 0;
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= 2 * n; i++) {
      dp[i][0] = 0;
      for (int j = 1; j <= n; j++) {
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + abs(a[j] - i));
      }
      ans = min(ans, dp[i][n]);
    }
    cout << ans << "\n";
  }
}
