#include <bits/stdc++.h>
using namespace std;
const int OO = (int)1e9;
const double EPS = (1e-7);
vector<vector<int> > v;
vector<int> vis;
bool valid(int r, int c, int n, int m) {
  return (r >= 0 && r < n && c >= 0 && c < m);
}
int dx[] = {1, 0, -1, 0, -1, 1, -1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
int dp[205][305], n;
vector<int> a;
int d_p(int i, int dif) {
  if (dif == 305) return 1e6;
  if (i == n) return 0;
  if (dp[i][dif] != -1) return dp[i][dif];
  return dp[i][dif] =
             min(d_p(i + 1, dif + 1) + abs(a[i] - dif), d_p(i, dif + 1));
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    memset(dp, -1, sizeof(dp));
    cin >> n;
    a = vector<int>(n, 0);
    for (int x = 0; x < n; x++) cin >> a[x];
    sort(((a).begin()), ((a).end()));
    cout << d_p(0, 1) << endl;
  }
}
