func_code_string: #pragma GCC optimize( -Ofast , -funroll-all-loops )   #pragma GCC optimize(2)   #pragma GCC optimize(3, Ofast , inline )   #include<bits/stdc++.h>   using namespace std;      typedef long long ll;   int _;   int n;   int a[30010];      void solve(){       cin >> _;       while(_--){           cin >> n;           int cnt0 = 0, cnt1 = 0, cnt2 = 0;           for(int i = 1; i <= n; i++){               cin >> a[i];               if(a[i] % 3 == 0){                   cnt0++;               }               else if(a[i] % 3 == 1){                   cnt1++;               }               else{                   cnt2++;               }           }           int need = n/3;           if(cnt0 == need && cnt1 == need && cnt2 == need){               cout <<  0  <<   n ;           }           else if(cnt0 > need && cnt1 > need && cnt2 < need){               cout << (cnt0-need)*2 + (cnt1-need) <<   n ;           }           else if(cnt0 < need && cnt1 > need && cnt2 > need){               cout << (cnt1-need)*2+(cnt2-need) <<   n ;           }           else if(cnt0 > need && cnt1 < need && cnt2 > need){               cout << (cnt0-need) + (cnt2-need)*2 <<   n ;           }           else if(cnt0 > need && cnt1 < need && cnt2 < need){               cout << (need-cnt1) + (need-cnt2)*2 <<   n ;           }           else if(cnt0 < need && cnt1 > need && cnt2 < need){               cout << (need-cnt2) + 2*(need-cnt0) <<   n ;           }           else if(cnt0 < need && cnt1 < need && cnt2 > need){               cout << (need-cnt0) + 2*(need-cnt1) <<   n ;           }           else if(cnt0 == need){               if(cnt1 > need && cnt2 < need){                   cout << (cnt1-need) <<   n ;               }               else{                   cout << 2*(cnt2-need) <<  n ;               }           }           else if(cnt1 == need){               if(cnt0 > need && cnt2 < need){                   cout << 2*(cnt0-need) <<   n ;               }               else{                   cout << (cnt2-need) <<   n ;               }           }           else if(cnt2 == need){               if(cnt0 > need && cnt1 < need){                   cout << (cnt0 - need) <<   n ;               }               else{                   cout << 2*(cnt1 - need) <<   n ;               }           }       }       return ;   }      int main(){       ios::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);              solve();       return 0;   }   