#include <bits/stdc++.h>
using namespace std;

#define f(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) f(i, 0, n)
#define repr(i, n) f(i, 1, n + 1)
#define fd(i, a, b) for (int i = a; i >= b; i--)
#define int long long
#define MOD 1000000007
#define INF 1e9 + 1
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0)
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
#define test   \
    int t = 1; \
    while (t--)
#define all(a) a.begin(), a.end()
#define mp make_pair

signed main()
{
    fast;
    tests
    {
        int n;
        cin>>n;
        vi cnt(3,0);
        int x;
        rep(i,n) {
            cin>>x;
            cnt[x%3]++;
        }
        int ans = 0;
        while(!(cnt[0] == cnt[1] && cnt[1] == cnt[2] && cnt[2] == cnt[0])) {
            int mx = max_element(all(cnt)) - cnt.begin();
            cnt[mx]--;
            cnt[(mx+1) % 3]++;
            ans++;
        }
        cout<<ans<<"\n";
        

    }
    return 0;
}
