#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& res) {
  char c;
  T flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  res *= flag;
}
const int inf = 0x3f3f3f3f;
const long long mod = 99991;
const int maxn = 4e2 + 5;
int n, m, t, u, v, tot;
int a[maxn], dp[maxn][maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = (1); i <= (n); ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (n * 2); ++j) dp[i][j] = inf;
    for (int i = (1); i <= (n); ++i) {
      for (int j = (i); j <= (n * 2); ++j) {
        for (int k = (i - 1); k <= (j - 1); ++k) {
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + abs(a[i] - j));
        }
      }
    }
    int ans = inf;
    for (int i = (1); i <= (n * 2); ++i) ans = min(ans, dp[n][i]);
    cout << ans << endl;
  }
  return 0;
}
