#include <bits/stdc++.h>
using namespace std;
int n, t;
int a[205], q[205];
int mem[205][1005];
int search(int step, int tim) {
  if (mem[step][tim] != -1) return mem[step][tim];
  if (step == n + 1) return 0;
  int res = 19260817;
  for (int i = tim + 1; i <= 5 * n; i++) {
    res = min(res, search(step + 1, i));
  }
  res += abs(tim - a[step]);
  return mem[step][tim] = res;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    memset(mem, -1, sizeof(mem));
    scanf("%d", &n);
    int sum = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    int ans = 2147483647;
    for (int i = 1; i <= n * 5; i++) ans = min(ans, search(1, i));
    printf("%d\n", ans);
  }
}
