#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
const int N = 200 + 5;
int dp[N * 2][N];
int a[N];
int n;
long long solve(int indx, int time) {
  if (indx == n) return 0;
  if (~dp[indx][time]) return dp[indx][time];
  long long ret = 0;
  ret = solve(indx + 1, time + 1) + abs(a[indx] - time);
  if (time < a[indx]) ret = min(solve(indx, time + 1), ret);
  return dp[indx][time] = ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    cout << solve(0, 1) << endl;
  }
  return 0;
}
