#include <bits/stdc++.h>
using namespace std;
const int maxn = 205, maxt = 355, inf = 1000000000;
int n, ans, t[maxn], dp[maxt][maxn];
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  sort(t + 1, t + n + 1);
  ans = inf;
  for (int i = 0; i < maxt; i++)
    for (int j = 0; j < maxn; j++) dp[i][j] = inf;
  dp[0][0] = 0;
  for (int i = 1; i < maxt; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 0; k < i; k++)
        dp[i][j] = min(dp[i][j], dp[k][j - 1] + abs(t[j] - i));
  for (int i = 1; i < maxt; i++) ans = min(ans, dp[i][n]);
  printf("%d\n", ans);
  return;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) solve();
  return 0;
}
