#include <bits/stdc++.h>
using namespace std;
int a[505];
long long dp[505][505];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    sort(a + 1, a + 1 + n);
    int inf = 1e8;
    for (int i = 1; i <= n; i++)
      for (int j = 2 * n; j >= 1; j--) dp[i][j] = inf;
    for (int i = 1; i <= n; i++)
      for (int j = 2 * n; j >= 1; j--)
        for (int k = 1; k <= n; k++) {
          if (j - k < i - 1 || dp[i - 1][j - k] == inf) continue;
          dp[i][j] = min(dp[i][j], dp[i - 1][j - k] + abs(j - a[i]));
        }
    long long ans = dp[n][n];
    for (int j = 2 * n; j >= n; j--) ans = min(ans, dp[n][j]);
    cout << ans << endl;
  }
}
