#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    vector<int> vect(n, 0);
    for (int i = int(0); i < int(n); i++) cin >> vect[i];
    sort(vect.begin(), vect.end());
    long long int inf = 1e17;
    vector<vector<long long int>> ans(1001, vector<long long int>(n + 1, inf));
    ans[1][0] = 0;
    for (int i = 1; i < 1000; i++) {
      for (int j = 0; j <= n; j++) {
        ans[i + 1][j] = min(ans[i][j], ans[i + 1][j]);
        if (j < n) {
          ans[i + 1][j + 1] =
              min(ans[i + 1][j + 1], ans[i][j] + 1LL * abs(i - vect[j]));
        }
      }
    }
    cout << ans[1000][n];
    cout << "\n";
  }
}
