#include <bits/stdc++.h>
using namespace std;
int n, t, a[205], f[205][410];
int main() {
  cin >> t;
  while (t--) {
    int mmin = 0x3f3f3f3f;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= 2 * n; i++) f[1][i] = abs(a[1] - i);
    for (int i = 2; i <= n; i++)
      for (int j = 1; j <= 2 * n; j++) f[i][j] = 0x3f3f3f3f;
    for (int i = 2; i <= n; i++)
      for (int j = 1; j <= 2 * n; j++)
        for (int k = 1; k < j; k++)
          f[i][j] = min(f[i][j], f[i - 1][k] + abs(a[i] - j));
    for (int i = 1; i <= 2 * n; i++) {
      mmin = min(f[n][i], mmin);
    }
    cout << mmin << endl;
  }
}
