#include <bits/stdc++.h>
const int INF = 2e9;
using namespace std;
int Q, n, t[205], dp[205][405];
int main() {
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
    sort(t + 1, t + n + 1);
    int N = 2 * t[n];
    if (N <= n) N = 2 * n;
    for (int i = 1; i <= n; i++)
      for (int T = 0; T <= N; T++) dp[i][T] = INF;
    for (int T = 1; T <= N; T++) dp[1][T] = min(dp[1][T - 1], abs(t[1] - T));
    for (int i = 2; i <= n; i++) {
      for (int T = 1; T <= N; T++)
        dp[i][T] = min(dp[i][T - 1], dp[i - 1][T - 1] + abs(T - t[i]));
    }
    int ds = INF;
    for (int T = 1; T <= N; T++) ds = min(ds, dp[n][T]);
    printf("%d\n", ds);
  }
}
