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