#include <bits/stdc++.h>
using namespace std;
int T, t[200010], n;
int dp[2000][2000];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n + n; ++j) dp[i][j] = (1 << 30);
    for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
    sort(t + 1, t + n + 1);
    for (int i = 1; i <= n; ++i) {
      for (int j = i; j <= n + n; ++j) {
        if (j == 1) {
          dp[i][j] = abs(t[i] - 1);
          continue;
        }
        for (int k = 1; k < j; ++k) {
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + abs(j - t[i]));
        }
      }
    }
    int ans = (1 << 30);
    for (int i = 1; i <= n + n; ++i) ans = min(ans, dp[n][i]);
    cout << ans << endl;
  }
  return 0;
}
