#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long INF64 = (long long)1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
template <class T1>
void deb(T1 e) {
  cout << "-->" << e << "\n";
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << "-->" << e1 << " " << e2 << "\n";
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << "\n";
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << "\n";
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5
       << "\n";
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << "-->" << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " "
       << e6 << "\n";
}
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
void RR(string& s, int l, int r, int k) {
  int n = int((s).size()) - 1;
  k %= (r - l + 1);
  s = s.substr(0, l) + s.substr(r - k + 1, k) + s.substr(l, r - l + 1 - k) +
      s.substr(r + 1, n - r);
}
template <typename T>
inline T gcd(T a, T b) {
  T c;
  while (b) {
    c = b;
    b = a % b;
    a = c;
  }
  return a;
}
long long lcm(int x, int y) { return x * 1LL * y / gcd(x, y); }
void read(vector<int>& v) {
  int N = int((v).size());
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
}
template <typename T>
T hungarian(const vector<vector<T>>& cost) {
  const T INFF = numeric_limits<T>::max();
  int n = cost.size(), m = cost[0].size();
  vector<T> u(n + 1), v(m + 1), dist(m + 1);
  vector<int> p(m + 1), way(m + 1), used(m + 1);
  for (int i = 1; i <= n; ++i) {
    p[0] = i;
    int j0 = 0;
    fill(dist.begin(), dist.end(), INFF);
    do {
      used[j0] = i;
      int i0 = p[j0], j1 = -1;
      T delta = INFF;
      for (int j = 1; j <= m; ++j)
        if (used[j] != i) {
          T cur = cost[i0 - 1][j - 1] - u[i0] - v[j];
          if (cur < dist[j]) dist[j] = cur, way[j] = j0;
          if (dist[j] < delta) delta = dist[j], j1 = j;
        }
      for (int j = 0; j < m + 1; j++) {
        if (used[j] == i)
          u[p[j]] += delta, v[j] -= delta;
        else
          dist[j] -= delta;
      }
      j0 = j1;
    } while (p[j0] != 0);
    for (int j1; j0; j0 = j1) p[j0] = p[j1 = way[j0]];
  }
  return -v[0];
}
void Answer() {
  int n;
  cin >> n;
  vector<int> v(n);
  read(v);
  vector<vector<int>> cost(n, vector<int>(2 * n));
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 2 * n; j++) {
      cost[i][j - 1] = abs(v[i] - j);
    }
  }
  cout << hungarian(cost) << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    Answer();
  }
  return 0;
}
