#include <bits/stdc++.h>
using namespace std;
int a[205];
int dp[2005][2005];
int ans;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 0; i <= 2 * n; i++) {
      for (int j = 0; j <= n; j++) {
        dp[i][j] = 0x3f3f3f3f;
      }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= 2 * n; i++) {
      for (int j = 0; j <= n; j++) {
        if (dp[i][j] < 0x3f3f3f3f) {
          dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
          if (j <= n - 1) {
            dp[i + 1][j + 1] =
                min(dp[i + 1][j + 1], dp[i][j] + abs(a[j + 1] - (i + 1)));
          }
        }
      }
    }
    ans = 0x3f3f3f3f;
    for (int i = 1; i <= 2 * n; i++) ans = min(ans, dp[i][n]);
    cout << ans << endl;
  }
  return 0;
}
