#include <bits/stdc++.h>
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T mymod(T x, T n, const T &p = -1) {
  T ret = 1;
  while (n > 0) {
    if (n & 1) {
      if (p != -1)
        ret = (ret * x) % p;
      else
        ret *= x;
    }
    if (p != -1)
      x = (x * x) % p;
    else
      x *= x;
    n >>= 1;
  }
  return ret;
}
ll gcd(ll n, ll m) {
  ll tmp;
  while (m != 0) {
    tmp = n % m;
    n = m;
    m = tmp;
  }
  return n;
}
ll lcm(ll n, ll m) { return abs(n) / gcd(n, m) * abs(m); }
using namespace std;
void solve() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = (int)0; i < (int)n; ++i) cin >> t[i];
    sort(t.begin(), t.end());
    constexpr int inf = 1e7;
    vector<vector<int>> dp(n + 1, vector<int>(500, inf));
    dp[0][0] = 0;
    for (int i = (int)0; i < (int)n; ++i) {
      for (int j = (int)0; j < (int)500; ++j) {
        for (int k = (int)j + 1; k < (int)500; ++k) {
          chmin(dp[i + 1][k], dp[i][j] + abs(t[i] - k));
        }
      }
    }
    int ans = inf;
    for (int i = (int)0; i < (int)500; ++i) chmin(ans, dp[n][i]);
    cout << ans << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
