#include <bits/stdc++.h>
using namespace std;
int ri() {
  int x;
  if (scanf(" %d", &x) == EOF) return -1;
  return x;
}
long long int rl() {
  long long int x;
  if (cin >> x) return x;
  return -1;
}
string rs() {
  string s;
  if (cin >> s) return s;
  return "";
}
const int inf = 10000000;
struct SingleCase {
  int n;
  vector<vector<int> > memo;
  vector<int> T;
  int doit(int slot, int x) {
    if (x >= T.size()) return 0;
    if (slot > 2 * n) return inf;
    int& ret = memo[slot][x];
    if (ret != -1) return ret;
    ret = inf;
    int dontTake = doit(slot + 1, x);
    int assign = doit(slot + 1, x + 1) + abs(T[x] - slot);
    return ret = min(ret, min(dontTake, assign));
  }
  bool solveCase() {
    n = ri();
    if (n < 0) return false;
    memo = vector<vector<int> >(2 * n + 1, vector<int>(n + 1, -1));
    for (int i = 0; i < n; ++i) T.push_back(ri());
    sort(T.begin(), T.end());
    int ret = doit(1, 0);
    cout << ret << endl;
    return true;
  }
};
int main() {
  ri();
  while (SingleCase().solveCase()) {
  };
  return 0;
}
