#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
class CChefMonocarp {
 public:
  void f(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
      in >> arr[i];
      arr[i]--;
    }
    sort(arr, arr + n);
    int max_minute = 2 * n + 2;
    int dp[n][max_minute];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < max_minute; j++) {
        dp[i][j] = INF;
      }
    }
    for (int i = 0; i < max_minute; i++) {
      dp[0][i] = abs(arr[0] - i);
    }
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < max_minute; j++) {
        for (int k = 0; k < j; k++) {
          int alt = dp[i - 1][k] + abs(arr[i] - j);
          dp[i][j] = min(dp[i][j], alt);
        }
      }
    }
    int myMin = INF;
    for (int i = 0; i < max_minute; i++) {
      myMin = min(myMin, dp[n - 1][i]);
    }
    out << myMin << endl;
  }
  void solve(std::istream& in, std::ostream& out) {
    int t;
    in >> t;
    while (t--) {
      f(in, out);
    }
  }
};
int main() {
  CChefMonocarp solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
