#include <bits/stdc++.h>
using namespace std;
int t;
int n;
int dp[500];
int arr[205];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &arr[i]);
    }
    sort(arr + 1, arr + 1 + n);
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i <= 2 * n; i++) {
      for (int j = n; j >= 1; j--) {
        dp[j] = min(dp[j - 1] + abs(arr[j] - i), dp[j]);
      }
    }
    printf("%d\n", dp[n]);
  }
  return 0;
}
