#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 3e3 + 5;
const int mod = 1e9 + 7;
const double eps = 1e-7;
int t, n;
int a[205], f[305][205];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    memset(f, 1e9 + 5, sizeof(f));
    f[0][0] = 0;
    int minn = 1e9 + 5;
    for (int i = 1; i <= 300; ++i) {
      f[i][0] = 0;
      for (int j = 1; j <= min(i, n); ++j) {
        f[i][j] = min(f[i][j], f[i - 1][j]);
        f[i][j] = min(f[i][j], f[i - 1][j - 1] + abs(i - a[j]));
      }
      if (i >= n) minn = min(minn, f[i][n]);
    }
    printf("%d\n", minn);
  }
  return 0;
}
