#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int dp[405][405];
int a[MAXN];
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);
    memset(dp, inf, sizeof dp);
    for (int i = 1; i <= 400; i++) {
      dp[1][i] = abs(i - a[1]);
    }
    for (int i = 2; i <= n; i++) {
      for (int j = i; j <= 400; j++) {
        for (int pre = i - 1; pre < j; pre++) {
          dp[i][j] = min(dp[i][j], dp[i - 1][pre] + abs(j - a[i]));
        }
      }
    }
    int ans = 1e9;
    for (int i = n; i <= 400; i++) {
      ans = min(ans, dp[n][i]);
    }
    printf("%d\n", ans);
  }
}
