#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
int T, n;
int t[maxn], dp[maxn * 2][maxn];
long long read() {
  long long s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * f;
}
int main() {
  T = read();
  while (T--) {
    memset(dp, 0x3f, sizeof(dp));
    n = read();
    for (int i = 1; i <= n; ++i) t[i] = read();
    sort(t + 1, t + 1 + n);
    for (int i = 0; i <= n + n; ++i) dp[i][0] = 0;
    for (int i = 1; i <= n + n; ++i) {
      for (int j = 1; j <= n; ++j) {
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + abs(i - t[j]));
      }
    }
    int ans = 1000000007;
    for (int i = n; i <= n + n; ++i) {
      ans = min(ans, dp[i][n]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
