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