#include <bits/stdc++.h>
using namespace std;
long long T, n, dp[205][505], t[205];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  while (T--) {
    cin >> n;
    for (long long i = 1; i <= n; i++) cin >> t[i];
    sort(t + 1, t + n + 1);
    for (long long i = 1; i <= n; i++) {
      dp[i][0] = 100000000;
      for (long long j = 1; j <= 500; j++) {
        dp[i][j] = min(dp[i - 1][j - 1] + abs(j - t[i]), dp[i][j - 1]);
      }
    }
    cout << dp[n][500] << '\n';
  }
}
