#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
int a[N], dp[N][N];
int aabs(int x) { return x >= 0 ? x : -x; }
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; ++i)
      for (int j = i; j <= 2 * n; ++j) {
        dp[i][j] = dp[i - 1][j - 1] + aabs(a[i] - j);
        if (j > i) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
      }
    cout << dp[n][2 * n] << endl;
  }
  return 0;
}
