   #include<bits/stdc++.h>
 using namespace std;
 typedef long long ll;
  
 typedef vector<int> vi;
 typedef vector<ll> vl;
 typedef vector<vi> vvi;
 typedef set<int> si;
 typedef set<ll> sl;
 typedef queue<int> qi;
 typedef queue<ll> ql;
 typedef stack<int> sti;
 typedef deque<int> dqi;
 typedef priority_queue<int> pqi;
 typedef priority_queue<ll> pql;
 typedef deque<ll> dql;
 typedef vector<vl> vvl;
 typedef pair<int,int> pii;
 typedef pair<double, double> pdd;
 typedef pair<ll, ll> pll;
 typedef vector<pii> vii;
 typedef vector<pll> vll;
 typedef double dl;
                    
 #define PB push_back
 
 #define F first
 #define S second
 #define MP make_pair
 #define el  '\n'
 #define sl(x) (int)x.length()
 #define all(a) (a).begin(),(a).end()
 #define sz(x) (int)x.size()
 #define mid(l,r) ((r+l)/2)
 #define left(node) (node*2)
 #define right(node) (node*2+1)
 #define mx_int_prime 999999937
#define loop(i,n)        for(int i=0;i<n;i++) 

 const double PI = acos(-1);
 const double eps = 1e-9;
 const int inf = 2000000000;
 const ll infLL = 9000000000000000000;
 #define MOD 1000000007
 #define in(n)  ll n;cin>>n;         
 #define mem(a,b) memset(a, b, sizeof(a) )
 #define gcd(a,b) __gcd(a,b)
 #define sqr(a) ((a) * (a))
 #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 #define fraction(a) cout.unsetf(ios::floatfield); cout.precision(a); cout.setf(ios::fixed,ios::floatfield);
 typedef vector<int>::iterator vit;
 typedef set<int>::iterator sit;
 int dx[] = {0, 0, +1, -1};
 int dy[] = {+1, -1, 0, 0};
   

 void solve(){
           in(n); 
     
    int c[3]={0};
    loop(i,n){
      in(x);
        c[x%3]++;
    }
    int cv=(c[0]+c[1]+c[2])/3;
    int ans=0;
    while(c[0]!=cv || c[1]!=cv || c[2]!=cv){
        if(c[0]>cv)c[0]--,c[1]++,ans++;
        if(c[1]>cv)c[1]--,c[2]++,ans++;
        if(c[2]>cv)c[2]--,c[0]++,ans++; 

    }
cout<<ans<<el;
 }
  int main(){
    optimize();
    in(t);
     while(t--){
       solve();
     }
     
      
    }