#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int hash[3]={0};
    for(int i=0;i<s.length();i++)
        hash[s[i]-'0']++;
    int req=n/3;
    if(hash[0]==hash[1] && hash[1]==hash[2])
    {
        cout<<s<<endl;
        return 0;
    }
    for(int i=0;i<s.length();i++)
    {
        if(hash[0]<req && hash[s[i]-'0']>req)
        {
            hash[0]++;
            hash[s[i]-'0']--;
            s[i]='0';
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[2]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='2';
            hash[2]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[0]>req)
        {
            if(s[i]=='0')
            {
                s[i]='1';
                hash[0]--;
                hash[1]++;
            }
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[2]>req)
        {
            if(s[i]=='2')
            {
                s[i]='1';
                hash[1]++;
                hash[2]--;
            }
        }
    }
    cout<<s<<endl;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int hash[3]={0};
    for(int i=0;i<s.length();i++)
        hash[s[i]-'0']++;
    int req=n/3;
    if(hash[0]==hash[1] && hash[1]==hash[2])
    {
        cout<<s<<endl;
        return 0;
    }
    for(int i=0;i<s.length();i++)
    {
        if(hash[0]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='0';
            hash[0]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[2]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='2';
            hash[2]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[0]>req)
        {
            if(s[i]=='0')
            {
                s[i]='1';
                hash[1]++;
                hash[0]--;
            }
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[2]>req)
        {
            if(s[i]=='2')
            {
                s[i]='1';
                hash[1]++;
                hash[2]--;
            }
        }
    }
    cout<<s<<endl;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int hash[3]={0};
    for(int i=0;i<s.length();i++)
        hash[s[i]-'0']++;
    int req=n/3;
    if(a[0]==a[1] && a[1]==a[2])
    {
        cout<<s<<endl;
        return 0;
    }
    for(int i=0;i<s.length();i++)
    {
        if(hash[0]<req && hash[s[i]-'0']>req)
        {
            hash[0]++;
            hash[s[i]-'0']--;
            s[i]='0';
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[2]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='2';
            hash[2]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[0]>req)
        {
            if(s[i]=='0')
            {
                s[i]='1';
                hash[0]--;
                hash[1]++;
            }
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[2]>req)
        {
            if(s[i]=='2')
            {
                s[i]='1';
                hash[1]++;
                hash[2]--;
            }
        }
    }
    cout<<s<<endl;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int hash[3]={0};
    for(int i=0;i<s.length();i++)
        hash[s[i]-'0']++;
    int req=n/3;
    if(hash[0]==hash[1] && hash[1]==hash[2])
    {
        cout<<s<<endl;
        return 0;
    }
    for(int i=0;i<s.length();i++)
    {
        if(hash[0]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='0';
            hash[0]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[2]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='2';
            hash[2]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[0]>req)
        {
            if(s[i]=='0')
            {
                s[i]='1';
                hash[1]++;
                hash[0]--;
            }
        }
    }
    for(ll i=0;i<n;i++)
    {
        if(hash[1]<req && hash[2]>req)
        {
            if(s[i]=='2')
            {
                s[i]='1';
                hash[1]++;
                hash[2]--;
            }
        }
    }
    cout<<s<<endl;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int hash[3]={0};
    for(int i=0;i<s.length();i++)
        hash[s[i]-'0']++;
    int req=n/3;
    for(int i=0;i<s.length();i++)
    {
        if(hash[0]<req && hash[s[i]-'0']>req)
        {
            hash[0]++;
            hash[s[i]-'0']--;
            s[i]='0';
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[2]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='2';
            hash[2]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[0]>req)
        {
            if(s[i]=='0')
            {
                s[i]='1';
                hash[0]--;
                hash[1]++;
            }
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[2]>req)
        {
            if(s[i]=='2')
            {
                s[i]='1';
                hash[1]++;
                hash[2]--;
            }
        }
    }
    cout<<s<<endl;
}


#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
int main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int hash[3]={0};
    for(int i=0;i<s.length();i++)
        hash[s[i]-'0']++;
    int req=n/3;
    for(int i=0;i<s.length();i++)
    {
        if(hash[0]<req && hash[s[i]-'0']>req)
        {
            s[i]='0';
            hash[0]++;
            hash[s[i]-'0']--;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[2]<req && hash[s[i]-'0']>req)
        {
            hash[s[i]-'0']--;
            s[i]='2';
            hash[2]++;
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[0]>req)
        {
            if(s[i]=='0')
            {
                s[i]='1';
                hash[0]--;
                hash[1]++;
            }
        }
    }
    for(int i=s.length()-1;i>=0;i--)
    {
        if(hash[1]<req && hash[2]>req)
        {
            if(s[i]=='2')
            {
                s[i]='1';
                hash[1]++;
                hash[2]--;
            }
        }
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define pii pair<int,int>
#define ff first
#define ss second
#define N 100005

using namespace std;

void need_for_speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int cnt[3];

int32_t main(){
    need_for_speed();
    int n;
    cin>>n;
    string s;
    cin>>s;
    int freq[3];
    memset(freq,0,sizeof(freq));
    int reqd=n/3;
    for(auto it:s) freq[it-'0']++;

    for(int i=0;i<n;i++){
        int curr=s[i]-'0';
        if(freq[curr]>reqd){
            for(int j=0;j<=curr-1;j++){
                if(freq[j]<reqd){
                    freq[j]++;
                    freq[curr]--;
                    s[i]=j+'0';
                    break;
                }
            }
        }
    }

    for(int i=n-1;i>=0;i--){
        int curr=s[i]-'0';
        if(freq[curr]>reqd){
            for(int j=2;j>=0;j--){
                if(freq[j]<reqd){
                    freq[j]++;
                    freq[curr]--;
                    s[i]=j+'0';
                    break;
                }
            }
        }
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define pii pair<int,int>
#define ff first
#define ss second
#define N 100005

using namespace std;

void need_for_speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int cnt[3];

int32_t main(){
    need_for_speed();
    int n;
    cin>>n;
    string str;
    cin>>str;
    int f=n/3;

    for(int i=0;i<n;i++) {
        cnt[str[i]-'0']++;
       // cnt[str[i]-'0'].ss=str[i]-'0';
    }
    priority_queue <pii, vector<pii>, greater<pii> > pq;
    pq.push({cnt[0],0});
    pq.push({cnt[1],1});
    pq.push({cnt[2],2});

    int pre[3];
    memset(pre,0,sizeof(pre));
    for(int i=n-1;i>=0;i--){
        pre[str[i]-'0']++;
        if(pre[str[i]-'0']>f){
            pii to_fill=pq.top();
            pq.pop();
            str[i]=to_fill.ss+'0';
            //pre[to_fill.ss]--;
            pq.push({to_fill.ff+1,to_fill.ss});

        }
    }
    cout<<str<<endl;
}


#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define pii pair<int,int>
#define ff first
#define ss second
#define N 100005

using namespace std;

void need_for_speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int cnt[3];

int32_t main(){
    need_for_speed();
    int n;
    cin>>n;
    string str;
    cin>>str;
    int f=n/3;

    for(int i=0;i<n;i++) {
        cnt[str[i]-'0']++;
       // cnt[str[i]-'0'].ss=str[i]-'0';
    }
    priority_queue <pii, vector<pii>, greater<pii> > pq;
    pq.push({cnt[0],0});
    pq.push({cnt[1],1});
    pq.push({cnt[2],2});

    int pre[3];
    memset(pre,0,sizeof(pre));
    for(int i=0;i<n;i++){
        pre[str[i]-'0']++;
        if(pre[str[i]-'0']>f){
            pii to_fill=pq.top();
            pq.pop();
            str[i]=to_fill.ss+'0';
            //pre[to_fill.ss]--;
            pq.push({to_fill.ff+1,to_fill.ss});

        }
    }
    cout<<str<<endl;
}


#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n)
{
  vector<ll> result;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    int count=1;
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                {
                  prime[i] = false;
                }
            count++;
        }
    }

    for (ll p=2; p<=n; p++)
       if (prime[p])
          {
            result.push_back(p);
          }
    return result;
}

vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

// int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        // cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            // cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
       {} // cout << n << " ";
}

unsigned int countSetBits(unsigned ll n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}

unsigned ll bin(int n)
{
  V<int> ans;
    unsigned i;
    for (i = 1 << 10; i > 0; i = i / 2)
        (n & i)? ans.pb(1): ans.pb(0);

    unsigned ll num=0;
    unsigned ll po=1;
    for(int i=ans.size()-1;i>=0;i--)
    {
      num=num+1ll*(ans[i]*po);
      po=po*10;
    }
    return num;
}

int main()
{
  _FI

  int n;
 cin>>n;
 int A[3]={0};
 string str;
 cin>>str;
 n= str.length();

 for(int i=0;i<n;i++)
  A[(str[i]-'0')]++;

 for(int i=0;i<n;i++)
 if(str[i]!='0' && A[0]<n/3)
   {
     int curr = (str[i]-'0');
     if( A[curr]>n/3 )
      {
         str[i]='0';
         A[curr]--;
         A[0]++;
      }
   }

 for(int i=n-1;i>=0;i--)
 if(str[i]=='0' && A[0]>n/3)
   {
     if( A[2]<n/3 )
      {
         str[i]= '2';
         A[2]++;
         A[0]--;
      }
     else
     if(A[1]<n/3)
     {
       str[i]='1';
       A[1]++;
       A[0]--;
     }
   }

 for(int i=n-1;i>=0;i--)
 if(str[i]!='2' && A[2]<n/3)
   {
     int curr = (str[i]-'0');
     if( A[curr]>n/3 )
      {
         str[i]='2';
         A[curr]--;
         A[2]++;
      }
   }

 for(int i=0;i<n;i++)
 if(str[i]=='2' && A[2]>n/3)
   {
     if( A[1]<n/3 )
      {
         str[i]= '1';
         A[1]++;
         A[2]--;
      }
     else
     if(A[0]<n/3)
     {
       str[i]='0';
       A[0]++;
       A[2]--;
     }
   }

   cout<<str<<endl;

  return 0;
}

// 201021111121111012111212


#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n)
{
  vector<ll> result;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    int count=1;
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                {
                  prime[i] = false;
                }
            count++;
        }
    }

    for (ll p=2; p<=n; p++)
       if (prime[p])
          {
            result.push_back(p);
          }
    return result;
}

vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

// int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        // cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            // cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
       {} // cout << n << " ";
}

unsigned int countSetBits(unsigned ll n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}

unsigned ll bin(int n)
{
  V<int> ans;
    unsigned i;
    for (i = 1 << 10; i > 0; i = i / 2)
        (n & i)? ans.pb(1): ans.pb(0);

    unsigned ll num=0;
    unsigned ll po=1;
    for(int i=ans.size()-1;i>=0;i--)
    {
      num=num+1ll*(ans[i]*po);
      po=po*10;
    }
    return num;
}

int main()
{
  _FI

  int n;
  cin>>n;
  string s;
  cin>>s;

  map<char,int> mp;
  for(int i=0;i<n;i++)
  {
    mp[s[i]]++;
  }

  int reqd=n/3;
  bool flag=true;
  for(auto it=mp.begin();it!=mp.end();it++)
  {
    if(it->S!=reqd)
    {
      flag=false;
      break;
    }
  }
  cerr<<"1"<<endl;
  if(flag)
  {
    cout<<s<<endl;
    return 0;
  }

  if(mp['0']==reqd)
  {
      cerr<<"here0"<<endl;
      int count1=mp['1'];
      int count2=mp['2'];
      if(count1<count2)
      {
         for(int i=0;i<n;i++)
          {
            if(count1==count2)
            {
              break;
            }
            if(s[i]=='2')
            {
              s[i]='1';
              count1++;
              count2--;
            }
          }
        }
      else
      {
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='1')
          {
            s[i]='2';
            count2++;
            count1--;
          }
          if(count1==count2)
          {
            break;
          }
         }

        }
    }

  else if(mp['1']==reqd)
  {
  cerr<<"here1"<<endl;

    int count0=mp['0'];
    int count2=mp['2'];

    if(count0<count2)
    {
      for(int i=0;i<n;i++)
      {
        if(count0==count2)
        {
          break;
        }
        if(s[i]=='2')
        {
          s[i]='0';
          count0++;
          count2--;
        }
      }
    }
    else
    {
        for(int i=n-1;i>=0;i--)
        {
          if(count0==count2)
          {
            break;
          }
         if(s[i]=='0')
          {
            s[i]='2';
            count2++;
            count0--;
          }
        }
     }
  }

  else if(mp['2']==reqd)
  {
  cerr<<"cerr2"<<endl;

    int count0=mp['0'];
    int count1=mp['1'];
    if(count0<count1)
    {
      for(int i=0;i<n;i++)
      {
        if(count1==count0)
        {
          break;
        }
        if(s[i]=='1')
        {
          s[i]='0';
          count0++;
          count1--;
        }
      }
    }
    else
    {
      for(int i=n-1;i>=0;i--)
      {
        if(count1==count0)
        {
          break;
        }
        if(s[i]=='0')
        {
          s[i]='1';
          count1++;
          count0--;
        }
      }
    }
  }

  else
  {
    cerr<<"here"<<endl;
    if(mp['0']>=reqd && mp['1']>=reqd)
    {
      int count1=0;
      int count0=0;
      for(int i=n-1;i>=0;i--)
      {
        if(s[i]=='1')
        {
          count1++;
          if(count1>reqd && mp['1']!=reqd)
          {
            mp['1']--;
            s[i]='2';
          }
        }
        else if(s[i]=='0')
        {
          count0++;
          if(count0>reqd && mp['0']!=reqd)
          {
            mp['0']--;
            s[i]='2';
          }
        }
      }
    }
    else if(mp['1']>=reqd && mp['2']>=reqd)
    {
      int count1=0;
      int count2=0;
      for(int i=0;i<n;i++)
      {
        if(s[i]=='1')
        {
          if(mp['1']!=reqd)
          {
            mp['1']--;
            s[i]='0';
          }
        }
        else if(s[i]=='2')
        {
          if(mp['2']!=reqd)
          {
            mp['2']--;
            s[i]='0';
          }
        }
      }
    }
    else if(mp['0']>=reqd && mp['2']>=reqd)
    {
      cerr<<"testing"<<endl;
      int count0=0;
      int count2=0;

      for(int i=0;i<n;i++)
      {
        if(s[i]=='2' && mp['2']!=reqd)
        {
          mp['2']--;
          s[i]='1';
        }
      }
      for(int i=n-1;i>=0;i--)
      {
        if(s[i]=='0' && mp['0']!=reqd)
        {
          mp['0']--;
          s[i]='1';
        }
      }
    }
    else
    {
      cerr<<"whatsup";
      if(mp['0']>reqd)
      {
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='0' && mp['2']!=reqd)
          {
            s[i]='2';
            mp['2']++;
          }
          else if(s[i]=='0' && mp['1']!=reqd)
          {
            s[i]='1';
            mp['1']++;
          }
        }
      }
      else if(mp['1']>reqd)
      {
        for(int i=0;i<n;i++)
        {
          if(s[i]=='1' && mp['0']!=reqd)
          {
            s[i]='0';
            mp['0']++;
          }
        }
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='1' && mp['2']!=reqd)
          {
            s[i]='2';
            mp['2']++;
          }
        }
      }
      else
      {
        for(int i=0;i<n;i++)
        {
          if(s[i]=='2' && mp['0']!=reqd)
          {
            s[i]='0';
            mp['0']++;
          }
          else if(s[i]=='2' && mp['1']!=reqd)
          {
            s[i]='1';
            mp['1']++;
          }
        }
      }
    }
  }

    cerr<<"The string is: ";
    cout<<s<<endl;

  return 0;
}

// 201021111121111012111212


#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n)
{
  vector<ll> result;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    int count=1;
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                {
                  prime[i] = false;
                }
            count++;
        }
    }

    for (ll p=2; p<=n; p++)
       if (prime[p])
          {
            result.push_back(p);
          }
    return result;
}

vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

// int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        // cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            // cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
       {} // cout << n << " ";
}

unsigned int countSetBits(unsigned ll n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}

unsigned ll bin(int n)
{
  V<int> ans;
    unsigned i;
    for (i = 1 << 10; i > 0; i = i / 2)
        (n & i)? ans.pb(1): ans.pb(0);

    unsigned ll num=0;
    unsigned ll po=1;
    for(int i=ans.size()-1;i>=0;i--)
    {
      num=num+1ll*(ans[i]*po);
      po=po*10;
    }
    return num;
}

int main()
{
  _FI

  int n;
  cin>>n;
  string s;
  cin>>s;

  map<char,int> mp;
  for(int i=0;i<n;i++)
  {
    mp[s[i]]++;
  }

  int reqd=n/3;
  bool flag=true;
  for(auto it=mp.begin();it!=mp.end();it++)
  {
    if(it->S!=reqd)
    {
      flag=false;
      break;
    }
  }
  cerr<<"1"<<endl;
  if(flag)
  {
    cout<<s<<endl;
    return 0;
  }

  if(mp['0']==reqd)
  {
      cerr<<"here0"<<endl;
      int count1=mp['1'];
      int count2=mp['2'];
      if(count1<count2)
      {
         for(int i=0;i<n;i++)
          {
            if(count1==count2)
            {
              break;
            }
            if(s[i]=='2')
            {
              s[i]='1';
              count1++;
              count2--;
            }
          }
        }
      else
      {
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='1')
          {
            s[i]='2';
            count2++;
            count1--;
          }
          if(count1==count2)
          {
            break;
          }
         }

        }
    }

  else if(mp['1']==reqd)
  {
  cerr<<"here1"<<endl;

    int count0=mp['0'];
    int count2=mp['2'];

    if(count0<count2)
    {
      for(int i=0;i<n;i++)
      {
        if(count0==count2)
        {
          break;
        }
        if(s[i]=='2')
        {
          s[i]='0';
          count0++;
          count2--;
        }
      }
    }
    else
    {
        for(int i=n-1;i>=0;i--)
        {
          if(count0==count2)
          {
            break;
          }
         if(s[i]=='0')
          {
            s[i]='2';
            count2++;
            count0--;
          }
        }
     }
  }

  else if(mp['2']==reqd)
  {
  cerr<<"cerr2"<<endl;

    int count0=mp['0'];
    int count1=mp['1'];
    if(count0<count1)
    {
      for(int i=0;i<n;i++)
      {
        if(count1==count0)
        {
          break;
        }
        if(s[i]=='1')
        {
          s[i]='0';
          count0++;
          count1--;
        }
      }
    }
    else
    {
      for(int i=n-1;i>=0;i--)
      {
        if(count1==count0)
        {
          break;
        }
        if(s[i]=='0')
        {
          s[i]='1';
          count1++;
          count0--;
        }
      }
    }
  }

  else
  {
    cerr<<"here"<<endl;
    if(mp['0']>reqd && mp['1']>reqd)
    {
      int count1=0;
      int count0=0;
      for(int i=n-1;i>=0;i--)
      {
        if(s[i]=='1')
        {
          count1++;
          if(count1>reqd && mp['1']!=reqd)
          {
            mp['1']--;
            s[i]='2';
          }
        }
        else if(s[i]=='0')
        {
          count0++;
          if(count0>reqd && mp['0']!=reqd)
          {
            mp['0']--;
            s[i]='2';
          }
        }
      }
    }
    else if(mp['1']>reqd && mp['2']>reqd)
    {
      int count1=0;
      int count2=0;
      for(int i=0;i<n;i++)
      {
        if(s[i]=='1')
        {
          if(mp['1']!=reqd)
          {
            mp['1']--;
            s[i]='0';
          }
        }
        else if(s[i]=='2')
        {
          if(mp['2']!=reqd)
          {
            mp['2']--;
            s[i]='0';
          }
        }
      }
    }
    else if(mp['0']>reqd && mp['2']>reqd)
    {
      int count0=0;
      int count2=0;

      for(int i=0;i<n;i++)
      {
        if(s[i]=='2' && mp['2']!=reqd)
        {
          mp['2']--;
          s[i]='1';
        }
      }
      for(int i=n-1;i>=0;i--)
      {
        if(s[i]=='0' && mp['0']!=reqd)
        {
          mp['0']--;
          s[i]='0';
        }
      }
    }
    else
    {
      cerr<<"whatsup";
      if(mp['0']>reqd)
      {
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='0' && mp['2']!=reqd)
          {
            s[i]='2';
            mp['2']++;
          }
          else if(s[i]=='0' && mp['1']!=reqd)
          {
            s[i]='1';
            mp['1']++;
          }
        }
      }
      else if(mp['1']>reqd)
      {
        for(int i=0;i<n;i++)
        {
          if(s[i]=='1' && mp['0']!=reqd)
          {
            s[i]='0';
            mp['0']++;
          }
        }
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='1' && mp['2']!=reqd)
          {
            s[i]='2';
            mp['2']++;
          }
        }
      }
      else
      {
        for(int i=0;i<n;i++)
        {
          if(s[i]=='2' && mp['0']!=reqd)
          {
            s[i]='0';
            mp['0']++;
          }
          else if(s[i]=='2' && mp['1']!=reqd)
          {
            s[i]='1';
            mp['1']++;
          }
        }
      }
    }
  }

    cerr<<"The string is: ";
    cout<<s<<endl;

  return 0;
}


#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n)
{
  vector<ll> result;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    int count=1;
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                {
                  prime[i] = false;
                }
            count++;
        }
    }

    for (ll p=2; p<=n; p++)
       if (prime[p])
          {
            result.push_back(p);
          }
    return result;
}

vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

ll Div(ll n)
{
  for(ll i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
      return i;
  }
  return n;
}

// int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        // cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            // cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
       {} // cout << n << " ";
}

unsigned int countSetBits(unsigned ll n)
{
    unsigned int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}

unsigned ll bin(int n)
{
  V<int> ans;
    unsigned i;
    for (i = 1 << 10; i > 0; i = i / 2)
        (n & i)? ans.pb(1): ans.pb(0);

    unsigned ll num=0;
    unsigned ll po=1;
    for(int i=ans.size()-1;i>=0;i--)
    {
      num=num+1ll*(ans[i]*po);
      po=po*10;
    }
    return num;
}

int main()
{
  _FI

  int n;
  cin>>n;
  string s;
  cin>>s;

  map<char,int> mp;
  for(int i=0;i<n;i++)
  {
    mp[s[i]]++;
  }

  int reqd=n/3;
  bool flag=true;
  for(auto it=mp.begin();it!=mp.end();it++)
  {
    if(it->S!=reqd)
    {
      flag=false;
      break;
    }
  }
  cerr<<"1"<<endl;
  if(flag)
  {
    cout<<s<<endl;
    return 0;
  }

  if(mp['0']==reqd)
  {
      cerr<<"here0"<<endl;
      int count1=mp['1'];
      int count2=mp['2'];
      if(count1<count2)
      {
         for(int i=0;i<n;i++)
          {
            if(count1==count2)
            {
              break;
            }
            if(s[i]=='2')
            {
              s[i]='1';
              count1++;
              count2--;
            }
          }
        }
      else
      {
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='1')
          {
            s[i]='2';
            count2++;
            count1--;
          }
          if(count1==count2)
          {
            break;
          }
         }

        }
    }

  else if(mp['1']==reqd)
  {
  cerr<<"here1"<<endl;

    int count0=mp['0'];
    int count2=mp['2'];

    if(count0<count2)
    {
      for(int i=0;i<n;i++)
      {
        if(count0==count2)
        {
          break;
        }
        if(s[i]=='2')
        {
          s[i]='0';
          count0++;
          count2--;
        }
      }
    }
    else
    {
        for(int i=n-1;i>=0;i--)
        {
          if(count0==count2)
          {
            break;
          }
         if(s[i]=='0')
          {
            s[i]='2';
            count2++;
            count0--;
          }
        }
     }
  }

  else if(mp['2']==reqd)
  {
  cerr<<"cerr2"<<endl;

    int count0=mp['0'];
    int count1=mp['1'];
    if(count0<count1)
    {
      for(int i=0;i<n;i++)
      {
        if(count1==count0)
        {
          break;
        }
        if(s[i]=='1')
        {
          s[i]='0';
          count0++;
          count1--;
        }
      }
    }
    else
    {
      for(int i=n-1;i>=0;i--)
      {
        if(count1==count0)
        {
          break;
        }
        if(s[i]=='0')
        {
          s[i]='1';
          count1++;
          count0--;
        }
      }
    }
  }

  else
  {
    cerr<<"here"<<endl;
    if(mp['0']>reqd && mp['1']>reqd)
    {
      int count1=0;
      int count0=0;
      for(int i=n-1;i>=0;i--)
      {
        if(s[i]=='1')
        {
          count1++;
          if(count1>reqd && mp['1']!=reqd)
          {
            mp['1']--;
            s[i]='2';
          }
        }
        else if(s[i]=='0')
        {
          count0++;
          if(count0>reqd && mp['0']!=reqd)
          {
            mp['0']--;
            s[i]='2';
          }
        }
      }
    }
    else if(mp['1']>reqd && mp['2']>reqd)
    {
      int count1=0;
      int count2=0;
      for(int i=0;i<n;i++)
      {
        if(s[i]=='1')
        {
          if(mp['1']!=reqd)
          {
            mp['1']--;
            s[i]='0';
          }
        }
        else if(s[i]=='2')
        {
          if(mp['2']!=reqd)
          {
            mp['2']--;
            s[i]='0';
          }
        }
      }
    }
    else if(mp['0']>reqd && mp['2']>reqd)
    {
      cerr<<"testing"<<endl;
      int count0=0;
      int count2=0;

      for(int i=0;i<n;i++)
      {
        if(s[i]=='2' && mp['2']!=reqd)
        {
          mp['2']--;
          s[i]='1';
        }
      }
      for(int i=n-1;i>=0;i--)
      {
        if(s[i]=='0' && mp['0']!=reqd)
        {
          mp['0']--;
          s[i]='1';
        }
      }
    }
    else
    {
      cerr<<"whatsup";
      if(mp['0']>reqd)
      {
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='0' && mp['2']!=reqd)
          {
            s[i]='2';
            mp['2']++;
          }
          else if(s[i]=='0' && mp['1']!=reqd)
          {
            s[i]='1';
            mp['1']++;
          }
        }
      }
      else if(mp['1']>reqd)
      {
        for(int i=0;i<n;i++)
        {
          if(s[i]=='1' && mp['0']!=reqd)
          {
            s[i]='0';
            mp['0']++;
          }
        }
        for(int i=n-1;i>=0;i--)
        {
          if(s[i]=='1' && mp['2']!=reqd)
          {
            s[i]='2';
            mp['2']++;
          }
        }
      }
      else
      {
        for(int i=0;i<n;i++)
        {
          if(s[i]=='2' && mp['0']!=reqd)
          {
            s[i]='0';
            mp['0']++;
          }
          else if(s[i]=='2' && mp['1']!=reqd)
          {
            s[i]='1';
            mp['1']++;
          }
        }
      }
    }
  }

    cerr<<"The string is: ";
    cout<<s<<endl;

  return 0;
}


                                                  //بسم الله الرحمن الرحيم
#include <bits/stdc++.h>
#define AllahIsTheGreatest ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define sec second
using namespace std;
typedef long long int ll;

string s;
int n;
map<int,int>mp;

int main()
{
    AllahIsTheGreatest;
    cin>>n>>s;
    for(auto x : s)mp[(int)x-48]++;
    while(mp[0]<n/3 && mp[2]>n/3){
        for(int i=0;i<s.size();i++){
            if(s[i]=='2'){
                mp[2]--;
                mp[0]++;
                s[i]='0';
                if(mp[0]==n/3)break;
            }
        }
    }while(mp[0]<n/3 && mp[1]>n/3){
        for(int i=0;i<s.size();i++){
            if(s[i]=='1'){
                mp[1]--;
                mp[0]++;
                s[i]='0';
                if(mp[0]==n/3)break;
            }
        }
    }while(mp[2]<n/3 && mp[1]>n/3){
        for(int i=s.size();i>=0;i--){
            if(s[i]=='1'){
                mp[1]--;
                mp[2]++;
                s[i]='2';
                if(mp[2]==n/3)break;
            }
        }
    }while(mp[2]<n/3 && mp[0]>n/3){
        for(int i=s.size();i>=0;i--){
            if(s[i]=='0'){
                mp[0]--;
                mp[2]++;
                s[i]='2';
                if(mp[2]==n/3)break;
            }
        }
    }while(mp[1]<n/3 && mp[2]>n/3){
        for(int i=0;i<s.size();i++){
            if(s[i]=='2'){
                mp[2]--;
                mp[1]++;
                s[i]='1';
                if(mp[1]==n/3)break;
            }
        }
    }while(mp[1]<n/3 && mp[0]>n/3){
        for(int i=s.size();i>=0;i--){
            if(s[i]=='0'){
                mp[0]--;
                mp[1]++;
                s[i]='1';
                if(mp[1]==n/3)break;
            }
        }
    }cout<<s<<endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define INPUT_FILE false
#define IF_FILE if(INPUT_FILE)
#define DEBUGING false
#define IF_DEBUG if(DEBUGING)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}

string s;
int m;
int n;
int cnt[3] = {0, 0, 0};
int id, minCnt = 0, maxCnt = 0;
list<int> pos[3];
vec<int> posToChange;
vec<int> toFill;

void balance() {

  FOR(i, 0, 3) {
    if (cnt[i] < m) {
      FOR(j, cnt[i], m) {
        toFill.push_back(i);
      }
    }
  }

  if (pos[1].size() > m) {
    if (pos[2].size() > m) {
      while (cnt[0] < m && pos[2].size() > m && pos[1].size() > m) {
        posToChange.push_back(min(pos[1].front(), pos[2].front()));
        if (pos[1].front() < pos[2].front()) {
          pos[1].pop_front();
          cnt[1]--;
        } else {
          pos[2].pop_front();
          cnt[2]--;
        }
        cnt[0]++;
        /*
        if (pos[1].size() == m || pos[2].size() == m) {
          break;
        }
        */
      }
      list<int> last = (pos[1].size() > m ? pos[1] : pos[2]);
      while (cnt[0] < m) {
        posToChange.push_back(last.front());
        last.pop_front();
        cnt[0]++;
      }
    } else {
      while (cnt[2] < m && pos[1].size() > m && pos[0].size() > m) {
        posToChange.push_back(max(pos[0].back(), pos[1].back()));
        if (pos[0].back() > pos[1].back()) {
          pos[0].pop_back();
          cnt[0]--;
        } else {
          pos[1].pop_back();
          cnt[1]--;
        }
        cnt[2]++;
      }
      list<int> last = (pos[0].size() > m ? pos[0] : pos[1]);
      while (cnt[2] < m) {
        posToChange.push_back(last.back());
        last.pop_back();
        cnt[2]++;
      }
    }
  } else {

  while (pos[0].size() > m) {
    posToChange.push_back(pos[0].back());
    pos[0].pop_back();
    cnt[0]--;
  }
  while (pos[2].size() > m) {
    posToChange.push_back(pos[2].front());
    pos[2].pop_front();
    cnt[2]--;
  }
  }

  sort(posToChange.begin(), posToChange.end());
  FOR(i, 0, toFill.size()) {
    s[posToChange[i]] = (char)('0' + toFill[i]);
  }

}

#undef int
int main() {
#define int long long
  ios_base::sync_with_stdio(false);
  cin.tie();
  IF_FILE {
    freopen("D.in", "r", stdin);
    cerr << "Remember to switch INPUT_FILE off before submitting!"
      << endl << endl;
    freopen("D.out", "w", stdout);
  }
  IF_DEBUG {
    cerr << "Remember to switch DEBUGING off before submitting!"
      << endl << endl;
  }

  {// Code goes here
    cin >> n;
    m = n / 3;
    cin >> s;
    FOR(i, 0, n) {
      id = s[i] - '0';
      pos[id].push_back(i);
      cnt[id]++;
      if (cnt[maxCnt] < cnt[id]) {
        maxCnt = id;
      }
      if (cnt[minCnt] > cnt[id]) {
        minCnt = id;
      }
    }
    IF_FILE {
      FOR(i, 0, 3) {
        cerr << cnt[i] << endl;
      }
    }
    balance();
    IF_FILE {
      FOR(i, 0, 3) {
        cerr << cnt[i] << endl;
      }
    }

    cout << s << endl;
    /*
       if (cnt[0] > k) {
       if (cnt[2] < k) {
       if (cnt[1] == k) {
       while (cnt[2] < k) {
       s[pos[0].back()] = '2';
       pos[0].pop_back();
       cnt[2]++;
       }
       } else if (cnt[1] > k) {

       }
       }
       }
     */
    /*
       if (cnt[minCnt] != cnt[maxCnt]) {
       int k = n / 3;
       if (maxCnt == 0) {
       FOR(i, 0, k - cnt[1]) {

       }
       }
       }
     */
  }

  IF_FILE {
    system("gnome-open D.in");
    system("gnome-open D.correct");
    system("gnome-open D.out");
    fstream myAns("D.out");
    fstream correctAns("D.correct");
    string myLine, correctLine;
    int lineIndex = 1;
    bool moreMyAns, moreCorrectAns;
    moreMyAns = (bool)getline(myAns, myLine);
    moreCorrectAns = (bool)getline(correctAns, correctLine);
    while (moreMyAns && moreCorrectAns) {
      cerr << lineIndex++ << "\t"
        << (myLine == correctLine ? "ok" : "WRONG") << endl;
      moreMyAns = (bool)getline(myAns, myLine);
      moreCorrectAns = (bool)getline(correctAns, correctLine);
    }
    if (moreMyAns) {
      cerr << "ERROR: My answer is too long! Excessive lines:" << endl;
      do {
        cerr << lineIndex++ << "\t"<< myLine << endl;
      } while (getline(myAns, myLine));
    } else if (moreCorrectAns) {
      cerr << "ERROR: My answer is too short! Missing lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << correctLine << endl;
      } while (getline(correctAns, correctLine));
    }
    myAns.flush();
    myAns.close();
    correctAns.flush();
    correctAns.close();
  }
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define INPUT_FILE false
#define IF_FILE if(INPUT_FILE)
#define DEBUGING false
#define IF_DEBUG if(DEBUGING)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}

string s;
int m;
int n;
int cnt[3] = {0, 0, 0};
int id, minCnt = 0, maxCnt = 0;
list<int> pos[3];
vec<int> posToChange;
vec<int> toFill;

void balance() {

  FOR(i, 0, 3) {
    if (cnt[i] < m) {
      FOR(j, cnt[i], m) {
        toFill.push_back(i);
      }
    }
  }

  if (pos[1].size() > m) {
    if (pos[2].size() >= m) {
      while (cnt[0] < m && pos[2].size() > m && pos[1].size() > m) {
        posToChange.push_back(min(pos[1].front(), pos[2].front()));
        if (pos[1].front() < pos[2].front()) {
          pos[1].pop_front();
          cnt[1]--;
        } else {
          pos[2].pop_front();
          cnt[2]--;
        }
        cnt[0]++;
        /*
           if (pos[1].size() == m || pos[2].size() == m) {
           break;
           }
         */
      }
      list<int> last = (pos[1].size() > m ? pos[1] : pos[2]);
      while (cnt[0] < m) {
        posToChange.push_back(last.front());
        last.pop_front();
        cnt[0]++;
      }
    } else {
      while (cnt[2] < m && pos[1].size() > m && pos[0].size() > m) {
        posToChange.push_back(max(pos[0].back(), pos[1].back()));
        if (pos[0].back() > pos[1].back()) {
          pos[0].pop_back();
          cnt[0]--;
        } else {
          pos[1].pop_back();
          cnt[1]--;
        }
        cnt[2]++;
      }
      list<int> last = (pos[0].size() > m ? pos[0] : pos[1]);
      while (cnt[2] < m) {
        posToChange.push_back(last.back());
        last.pop_back();
        cnt[2]++;
      }
    }
  } else {

    while (pos[0].size() > m) {
      posToChange.push_back(pos[0].back());
      pos[0].pop_back();
      cnt[0]--;
    }
    while (pos[2].size() > m) {
      posToChange.push_back(pos[2].front());
      pos[2].pop_front();
      cnt[2]--;
    }
  }

  sort(posToChange.begin(), posToChange.end());
  FOR(i, 0, toFill.size()) {
    s[posToChange[i]] = (char)('0' + toFill[i]);
  }

}

#undef int
int main() {
#define int long long
  ios_base::sync_with_stdio(false);
  cin.tie();
  IF_FILE {
    freopen("D.in", "r", stdin);
    cerr << "Remember to switch INPUT_FILE off before submitting!"
      << endl << endl;
    freopen("D.out", "w", stdout);
  }
  IF_DEBUG {
    cerr << "Remember to switch DEBUGING off before submitting!"
      << endl << endl;
  }

  {// Code goes here
    cin >> n;
    m = n / 3;
    cin >> s;
    FOR(i, 0, n) {
      id = s[i] - '0';
      pos[id].push_back(i);
      cnt[id]++;
      if (cnt[maxCnt] < cnt[id]) {
        maxCnt = id;
      }
      if (cnt[minCnt] > cnt[id]) {
        minCnt = id;
      }
    }
    IF_FILE {
      FOR(i, 0, 3) {
        cerr << cnt[i] << endl;
      }
    }
    balance();
    IF_FILE {
      FOR(i, 0, 3) {
        cerr << cnt[i] << endl;
      }
    }

    cout << s << endl;
    /*
       if (cnt[0] > k) {
       if (cnt[2] < k) {
       if (cnt[1] == k) {
       while (cnt[2] < k) {
       s[pos[0].back()] = '2';
       pos[0].pop_back();
       cnt[2]++;
       }
       } else if (cnt[1] > k) {

       }
       }
       }
     */
    /*
       if (cnt[minCnt] != cnt[maxCnt]) {
       int k = n / 3;
       if (maxCnt == 0) {
       FOR(i, 0, k - cnt[1]) {

       }
       }
       }
     */
  }

  IF_FILE {
    system("gnome-open D.in");
    system("gnome-open D.correct");
    system("gnome-open D.out");
    fstream myAns("D.out");
    fstream correctAns("D.correct");
    string myLine, correctLine;
    int lineIndex = 1;
    bool moreMyAns, moreCorrectAns;
    moreMyAns = (bool)getline(myAns, myLine);
    moreCorrectAns = (bool)getline(correctAns, correctLine);
    while (moreMyAns && moreCorrectAns) {
      cerr << lineIndex++ << "\t"
        << (myLine == correctLine ? "ok" : "WRONG") << endl;
      moreMyAns = (bool)getline(myAns, myLine);
      moreCorrectAns = (bool)getline(correctAns, correctLine);
    }
    if (moreMyAns) {
      cerr << "ERROR: My answer is too long! Excessive lines:" << endl;
      do {
        cerr << lineIndex++ << "\t"<< myLine << endl;
      } while (getline(myAns, myLine));
    } else if (moreCorrectAns) {
      cerr << "ERROR: My answer is too short! Missing lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << correctLine << endl;
      } while (getline(correctAns, correctLine));
    }
    myAns.flush();
    myAns.close();
    correctAns.flush();
    correctAns.close();
  }
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define INPUT_FILE false
#define IF_FILE if(INPUT_FILE)
#define DEBUGING false
#define IF_DEBUG if(DEBUGING)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}

string s;
int m;
int n;
int cnt[3] = {0, 0, 0};
int id, minCnt = 0, maxCnt = 0;
list<int> pos[3];
vec<int> posToChange;
vec<int> toFill;

void balance() {
  FOR(i, 0, 3) {
    if (cnt[i] < m) {
      FOR(j, cnt[i], m) {
        toFill.push_back(i);
      }
    }
  }

  while (pos[0].size() > m) {
    posToChange.push_back(pos[0].back());
    pos[0].pop_back();
    cnt[0]--;
  }
  while (pos[2].size() > m) {
    posToChange.push_back(pos[2].front());
    pos[2].pop_front();
    cnt[2]--;
  }
  while (pos[1].size() > m) {
    while (cnt[0] < m) {
      posToChange.push_back(pos[1].front());
      pos[1].pop_front();
      cnt[1]--;
      cnt[0]++;
    }
    while (cnt[2] < m) {
      posToChange.push_back(pos[1].back());
      pos[1].pop_back();
      cnt[1]--;
      cnt[2]++;
    }
  }
  sort(posToChange.begin(), posToChange.end());
  FOR(i, 0, toFill.size()) {
    s[posToChange[i]] = (char)('0' + toFill[i]);
  }

            /*
               FOR(i, 0, 3) {
               if (cnt[i] > m) {
               FOR(j, 0, 3) {
               if (j < i) {
               while (cnt[i] > m && cnt[j] < m) {
               s[pos[i].front()] = (char)('0' + j);
               pos[i].pop_front();
               cnt[i]--;
               cnt[j]++;
               }
               break;
               }

               }
               }
               }
             */
/*
   FOR(i, 0, n) {
   id = s[i] - '0';
   if (cnt[id] > m) {
   bool changed = false;
   FOR(j, 0, 2) {
   if (j < id && cnt[j] < m) {
   s[i] = (char)('0' + j);
   IF_FILE {
   cerr << s << endl;
   }
   cnt[id]--, cnt[j]++;
   changed = true;
   break;
   }
   }
   if (!changed) {
   FORD(j, 2, 1) {
   if (j > id && cnt[j] < m) {
   s[i] = (char)('0' + j);
   IF_FILE {
   cerr << s << endl;
   }
   cnt[id]--, cnt[j]++;
   changed = true;
   break;
   }
   }
   }
   }
   }
 */
/*
   FOR(i, 0, 3) {
   if (cnt[i] < m) {
   IF_FILE {
   cerr << "i = " << i << endl;
   }
   FOR(k, 0, 2) {
   int j = (i - k + 2) % 3;
   IF_FILE {
   cerr << "j = " << j << endl;
   }
   bool less = i < j;
   while (cnt[i] < m && cnt[j] > m) {
   cnt[i]++, cnt[j]--;
//s[pos[j].(less ? front() : back())] = '0' + i;
//pos[j].(less ? pop_front() : pop_back());
if (less) {
s[pos[j].front()] =(char)( '0' + i);
pos[j].pop_front();
} else {
s[pos[j].back()] =(char)( '0' + i);
pos[j].pop_back();
}
}
if (cnt[i] == k) {
break;
}
}
}
}
 */
}

#undef int
int main() {
#define int long long
  ios_base::sync_with_stdio(false);
  cin.tie();
  IF_FILE {
    freopen("D.in", "r", stdin);
    cerr << "Remember to switch INPUT_FILE off before submitting!"
      << endl << endl;
    freopen("D.out", "w", stdout);
  }
  IF_DEBUG {
    cerr << "Remember to switch DEBUGING off before submitting!"
      << endl << endl;
  }

  {// Code goes here
    cin >> n;
    m = n / 3;
    cin >> s;
    FOR(i, 0, n) {
      id = s[i] - '0';
      pos[id].push_back(i);
      cnt[id]++;
      if (cnt[maxCnt] < cnt[id]) {
        maxCnt = id;
      }
      if (cnt[minCnt] > cnt[id]) {
        minCnt = id;
      }
    }
    IF_FILE {
      FOR(i, 0, 3) {
        cerr << cnt[i] << endl;
      }
    }
    balance();
    IF_FILE {
      FOR(i, 0, 3) {
        cerr << cnt[i] << endl;
      }
    }

    cout << s << endl;
    /*
       if (cnt[0] > k) {
       if (cnt[2] < k) {
       if (cnt[1] == k) {
       while (cnt[2] < k) {
       s[pos[0].back()] = '2';
       pos[0].pop_back();
       cnt[2]++;
       }
       } else if (cnt[1] > k) {

       }
       }
       }
     */
    /*
       if (cnt[minCnt] != cnt[maxCnt]) {
       int k = n / 3;
       if (maxCnt == 0) {
       FOR(i, 0, k - cnt[1]) {

       }
       }
       }
     */
  }

  IF_FILE {
    system("gnome-open D.in");
    system("gnome-open D.correct");
    system("gnome-open D.out");
    fstream myAns("D.out");
    fstream correctAns("D.correct");
    string myLine, correctLine;
    int lineIndex = 1;
    bool moreMyAns, moreCorrectAns;
    moreMyAns = (bool)getline(myAns, myLine);
    moreCorrectAns = (bool)getline(correctAns, correctLine);
    while (moreMyAns && moreCorrectAns) {
      cerr << lineIndex++ << "\t"
        << (myLine == correctLine ? "ok" : "WRONG") << endl;
      moreMyAns = (bool)getline(myAns, myLine);
      moreCorrectAns = (bool)getline(correctAns, correctLine);
    }
    if (moreMyAns) {
      cerr << "ERROR: My answer is too long! Excessive lines:" << endl;
      do {
        cerr << lineIndex++ << "\t"<< myLine << endl;
      } while (getline(myAns, myLine));
    } else if (moreCorrectAns) {
      cerr << "ERROR: My answer is too short! Missing lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << correctLine << endl;
      } while (getline(correctAns, correctLine));
    }
    myAns.flush();
    myAns.close();
    correctAns.flush();
    correctAns.close();
  }
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define INPUT_FILE false
#define IF_FILE if(INPUT_FILE)
#define DEBUGING false
#define IF_DEBUG if(DEBUGING)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}

string s;
int m;
int n;
int cnt[3] = {0, 0, 0};
int id;
list<int> pos[3];
vec<int> posToChange;
vec<int> toFill;

void balance() {
  FOR(i, 0, 3) {
    if (cnt[i] < m) {
      FOR(j, cnt[i], m) {
        toFill.push_back(i);
      }
    }
  }
  if (pos[1].size() > m) {
    if (pos[2].size() >= m) {
      while (cnt[0] < m && pos[2].size() > m && pos[1].size() > m) {
        posToChange.push_back(min(pos[1].front(), pos[2].front()));
        if (pos[1].front() < pos[2].front()) {
          pos[1].pop_front();
          cnt[1]--;
        } else {
          pos[2].pop_front();
          cnt[2]--;
        }
        cnt[0]++;
      }
      list<int> last = (pos[1].size() > m ? pos[1] : pos[2]);
      while (cnt[0] < m) {
        posToChange.push_back(last.front());
        last.pop_front();
        cnt[0]++;
      }
    } else if (pos[0].size() >= m) {
      while (cnt[2] < m && pos[1].size() > m && pos[0].size() > m) {
        posToChange.push_back(max(pos[0].back(), pos[1].back()));
        if (pos[0].back() > pos[1].back()) {
          pos[0].pop_back();
          cnt[0]--;
        } else {
          pos[1].pop_back();
          cnt[1]--;
        }
        cnt[2]++;
      }
      list<int> last = (pos[0].size() > m ? pos[0] : pos[1]);
      while (cnt[2] < m) {
        posToChange.push_back(last.back());
        last.pop_back();
        cnt[2]++;
      }
    } else {
      while (cnt[0] < m) {
        posToChange.push_back(pos[1].front());
        pos[1].pop_front();
        cnt[0]++;
      }
      while (cnt[2] < m) {
        posToChange.push_back(pos[1].back());
        pos[1].pop_back();
        cnt[2]++;
      }
    }
  } else {
    while (pos[0].size() > m) {
      posToChange.push_back(pos[0].back());
      pos[0].pop_back();
      cnt[0]--;
    }
    while (pos[2].size() > m) {
      posToChange.push_back(pos[2].front());
      pos[2].pop_front();
      cnt[2]--;
    }
  }
  sort(posToChange.begin(), posToChange.end());
  FOR(i, 0, toFill.size()) {
    s[posToChange[i]] = (char)('0' + toFill[i]);
  }
}

#undef int
int main() {
#define int long long
  ios_base::sync_with_stdio(false);
  cin.tie();
  IF_FILE {
    freopen("D.in", "r", stdin);
    cerr << "Remember to switch INPUT_FILE off before submitting!"
      << endl << endl;
    freopen("D.out", "w", stdout);
  }
  IF_DEBUG {
    cerr << "Remember to switch DEBUGING off before submitting!"
      << endl << endl;
  }

  {// Code goes here
    cin >> n;
    m = n / 3;
    cin >> s;
    FOR(i, 0, n) {
      id = s[i] - '0';
      pos[id].push_back(i);
      cnt[id]++;
    }
    balance();
    cout << s << endl;
  }

  IF_FILE {
    system("gnome-open D.in");
    system("gnome-open D.correct");
    system("gnome-open D.out");
    fstream myAns("D.out");
    fstream correctAns("D.correct");
    string myLine, correctLine;
    int lineIndex = 1;
    bool moreMyAns, moreCorrectAns;
    moreMyAns = (bool)getline(myAns, myLine);
    moreCorrectAns = (bool)getline(correctAns, correctLine);
    while (moreMyAns && moreCorrectAns) {
      cerr << lineIndex++ << "\t"
        << (myLine == correctLine ? "ok" : "WRONG") << endl;
      moreMyAns = (bool)getline(myAns, myLine);
      moreCorrectAns = (bool)getline(correctAns, correctLine);
    }
    if (moreMyAns) {
      cerr << "ERROR: My answer is too long! Excessive lines:" << endl;
      do {
        cerr << lineIndex++ << "\t"<< myLine << endl;
      } while (getline(myAns, myLine));
    } else if (moreCorrectAns) {
      cerr << "ERROR: My answer is too short! Missing lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << correctLine << endl;
      } while (getline(correctAns, correctLine));
    }
    myAns.flush();
    myAns.close();
    correctAns.flush();
    correctAns.close();
  }
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define INPUT_FILE false
#define IF_FILE if(INPUT_FILE)
#define DEBUGING false
#define IF_DEBUG if(DEBUGING)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}

string s;
int m;
int n;
int cnt[3] = {0, 0, 0};
int id;
list<int> pos[3];
vec<int> posToChange;
vec<int> toFill;

void balance() {
  FOR(i, 0, 3) {
    if (cnt[i] < m) {
      FOR(j, cnt[i], m) {
        toFill.push_back(i);
      }
    }
  }
  if (pos[1].size() > m) {
    if (pos[2].size() >= m) {
      while (cnt[0] < m && pos[2].size() > m && pos[1].size() > m) {
        posToChange.push_back(min(pos[1].front(), pos[2].front()));
        if (pos[1].front() < pos[2].front()) {
          pos[1].pop_front();
          cnt[1]--;
        } else {
          pos[2].pop_front();
          cnt[2]--;
        }
        cnt[0]++;
      }
      list<int> last = (pos[1].size() > m ? pos[1] : pos[2]);
      while (cnt[0] < m) {
        posToChange.push_back(last.front());
        last.pop_front();
        cnt[0]++;
      }
    } else {
      while (cnt[2] < m && pos[1].size() > m && pos[0].size() > m) {
        posToChange.push_back(max(pos[0].back(), pos[1].back()));
        if (pos[0].back() > pos[1].back()) {
          pos[0].pop_back();
          cnt[0]--;
        } else {
          pos[1].pop_back();
          cnt[1]--;
        }
        cnt[2]++;
      }
      list<int> last = (pos[0].size() > m ? pos[0] : pos[1]);
      while (cnt[2] < m) {
        posToChange.push_back(last.back());
        last.pop_back();
        cnt[2]++;
      }
    }
  } else {
    while (pos[0].size() > m) {
      posToChange.push_back(pos[0].back());
      pos[0].pop_back();
      cnt[0]--;
    }
    while (pos[2].size() > m) {
      posToChange.push_back(pos[2].front());
      pos[2].pop_front();
      cnt[2]--;
    }
  }
  sort(posToChange.begin(), posToChange.end());
  FOR(i, 0, toFill.size()) {
    s[posToChange[i]] = (char)('0' + toFill[i]);
  }
}

#undef int
int main() {
#define int long long
  ios_base::sync_with_stdio(false);
  cin.tie();
  IF_FILE {
    freopen("D.in", "r", stdin);
    cerr << "Remember to switch INPUT_FILE off before submitting!"
      << endl << endl;
    freopen("D.out", "w", stdout);
  }
  IF_DEBUG {
    cerr << "Remember to switch DEBUGING off before submitting!"
      << endl << endl;
  }

  {// Code goes here
    cin >> n;
    m = n / 3;
    cin >> s;
    FOR(i, 0, n) {
      id = s[i] - '0';
      pos[id].push_back(i);
      cnt[id]++;
    }
    balance();
    cout << s << endl;
  }

  IF_FILE {
    system("gnome-open D.in");
    system("gnome-open D.correct");
    system("gnome-open D.out");
    fstream myAns("D.out");
    fstream correctAns("D.correct");
    string myLine, correctLine;
    int lineIndex = 1;
    bool moreMyAns, moreCorrectAns;
    moreMyAns = (bool)getline(myAns, myLine);
    moreCorrectAns = (bool)getline(correctAns, correctLine);
    while (moreMyAns && moreCorrectAns) {
      cerr << lineIndex++ << "\t"
        << (myLine == correctLine ? "ok" : "WRONG") << endl;
      moreMyAns = (bool)getline(myAns, myLine);
      moreCorrectAns = (bool)getline(correctAns, correctLine);
    }
    if (moreMyAns) {
      cerr << "ERROR: My answer is too long! Excessive lines:" << endl;
      do {
        cerr << lineIndex++ << "\t"<< myLine << endl;
      } while (getline(myAns, myLine));
    } else if (moreCorrectAns) {
      cerr << "ERROR: My answer is too short! Missing lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << correctLine << endl;
      } while (getline(correctAns, correctLine));
    }
    myAns.flush();
    myAns.close();
    correctAns.flush();
    correctAns.close();
  }
  return 0;
}


#include<iostream>
using namespace std;
int size[3];
int main(){
	int n,i,j,k;
	string s;
	cin>>n>>s;
	for(i=0;i<n;i++){
		size[(int)(s[i]-'0')]++;
	}
	for(i=0;i<n;i++){
		if(size[(int)(s[i]-'0')]>n/3){
			for(i=0;i<=2;i++){
				if(size[i]<n/3){
					size[i]++;
					size[(int)(s[i]-'0')]--;
					s[i]=i+'0';
				}
			}
		}
	}
	cout<<s;
}


#include<iostream>
using namespace std;
int size[3];
int main(){
	int n,i,j,k;
	string s;
	cin>>n>>s;
	for(i=0;i<n;i++){
		size[(int)(s[i]-'0')]++;
	}
	for(i=0;i<n;i++){
		if(size[(int)(s[i]-'0')]>n/3){
			for(j=0;j<=2;j++){
				if(size[j]<n/3){
					size[j]++;
					size[(int)(s[i]-'0')]--;
					s[i]=j+'0';
				}
			}
		}
	}
	cout<<s;
}


#include<iostream>
using namespace std;
int size[3];
int main(){
	int n,i,j,k;
	string s;
	cin>>n>>s;
	for(i=0;i<n;i++){
		size[(int)(s[i]-'0')]++;
	}
	for(i=n-1;i>=0;i--){
		if(size[(int)(s[i]-'0')]>n/3){
			for(j=0;j<=2;j++){
				if(size[j]<n/3){
					size[j]++;
					size[(int)(s[i]-'0')]--;
					s[i]=j+'0';
				}
			}
		}
	}
	cout<<s;
}


#include <bits/stdc++.h>
#define fill(x,c) memset(x,c,sizeof(x))
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const long long LL_INF = (long long) 2e18 + 5;
const int SIZE = 1e6+10;
ll n;
int a[SIZE];
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
	cin>>n;
	string s;cin>>s;ll tar = n/3,cnt=0;
	ll x=0,y=0,z=0;
	for(int i=0;i<n;i++){
		if(s[i]=='0')x++;
		if(s[i]=='1')y++;
		if(s[i]=='2')z++;
	}
	if(x==y&&y==z){
		cout<<s;return 0;
	}
	if(x>tar&&y<=tar&&z<=tar){
		int t = 0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t++;
			if(t>tar&&s[i]=='0'&&y<tar){
				s[i] = '1';y++;
			}else if(t>tar&&s[i]=='0'&&z<tar){
				s[i] = '2';z++;
			}
		}
	}else if(y>tar&&x<=tar&&z<=tar){
		int t=0;
		for(int i=0;i<n;i++){
			if(s[i]=='1'&&x<tar){
			s[i] = '0';x++;
		}
		if(s[i]=='1'&&x==tar)t++;
		if(t>tar&&s[i]=='1'&&z<tar){
			s[i] = '2';z++;
		}
		}
	}else if(z>tar&&y<=tar&&x<=tar){
		for(int i=0;i<n;i++){
			if(s[i]=='2'&&x<tar){
			s[i] = '0';x++;
		}else if(s[i]=='2'&&y<tar){
			s[i] = '1';y++;
		}
		}
	}else if(z>tar&&y>tar&&x<=tar){
		for(int i=0;i<n;i++){
			if(s[i]=='1'||s[i]=='2'&&x<tar){
				s[i]='0';x++;
			}
		}
	}else if(x>tar&&z>tar&&y<=tar){
		int t=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t++;
			if(s[i]=='0'&&t>tar&&y<tar){
				s[i] = '1';y++;
			}else if(s[i]=='2'&&y<tar){
				s[i] = '1';y++;
			}
		}
	}else if(x>tar&&y>tar&&z<=tar){
		int t0=0,t1=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t0++;
			if(s[i]=='1')t1++;
			if(s[i]=='0'&&t0>tar&&z<tar){
				s[i] = '2';z++;
			}
			if(s[i]=='1'&&t1>tar&&z<tar){
				s[i] = '2';z++;
			}
		}
	}
	cout<<s;
	return 0;
}


#include <bits/stdc++.h>
#define fill(x,c) memset(x,c,sizeof(x))
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const long long LL_INF = (long long) 2e18 + 5;
const int SIZE = 1e6+10;
ll n;
int a[SIZE];
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
	cin>>n;
	string s;cin>>s;ll tar = n/3,cnt=0;
	ll x=0,y=0,z=0;
	for(int i=0;i<n;i++){
		if(s[i]=='0')x++;
		if(s[i]=='1')y++;
		if(s[i]=='2')z++;
	}
	if(x==y&&y==z){
		cout<<s;return 0;
	}
	if(x>tar&&y<=tar&&z<=tar){
		int t = 0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t++;
			if(t>tar&&s[i]=='0'&&y<tar){
				s[i] = '1';y++;
			}else if(t>tar&&s[i]=='0'&&z<tar){
				s[i] = '2';z++;
			}
		}
	}else if(y>tar&&x<=tar&&z<=tar){
		int t=0;
		for(int i=0;i<n;i++){
			if(s[i]=='1'&&x<tar){
			s[i] = '0';x++;
		}
		if(s[i]=='1'&&x==tar)t++;
		if(t>tar&&s[i]=='1'&&z<tar){
			s[i] = '2';z++;
		}
		}
	}else if(z>tar&&y<=tar&&x<=tar){
		for(int i=0;i<n;i++){
			if(s[i]=='2'&&x<tar){
			s[i] = '0';x++;
		}else if(s[i]=='2'&&y<tar){
			s[i] = '1';y++;
		}
		}
	}else if(z>tar&&y>tar&&x<=tar){
		for(int i=0;i<n;i++){
			if((s[i]=='1'||s[i]=='2')&&x<tar){
				s[i]='0';x++;
			}
		}
	}else if(x>tar&&z>tar&&y<=tar){
		int t0=0,t2=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t0++;
			if(s[i]=='2')t2++;
			if(s[i]=='0'&&t0>tar&&y<tar){
				s[i] = '1';y++;
			}
			if(s[i]=='2'&&t2>tar&&y<tar){
				s[i] = '1';y++;
			}
		}
	}else if(x>tar&&y>tar&&z<=tar){
		int t0=0,t1=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t0++;
			if(s[i]=='1')t1++;
			if(s[i]=='0'&&t0>tar&&z<tar){
				s[i] = '2';z++;
			}
			if(s[i]=='1'&&t1>tar&&z<tar){
				s[i] = '2';z++;
			}
		}
	}
	cout<<s;
	return 0;
}


#include <bits/stdc++.h>
#define fill(x,c) memset(x,c,sizeof(x))
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const long long LL_INF = (long long) 2e18 + 5;
const int SIZE = 1e6+10;
ll n;
int a[SIZE];
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
	cin>>n;
	string s;cin>>s;ll tar = n/3,cnt=0;
	ll x=0,y=0,z=0;
	for(int i=0;i<n;i++){
		if(s[i]=='0')x++;
		if(s[i]=='1')y++;
		if(s[i]=='2')z++;
	}
	if(x==y&&y==z){
		cout<<s;return 0;
	}
	if(x>tar&&y<=tar&&z<=tar){
		int t = 0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t++;
			if(t>tar&&s[i]=='0'&&y<tar){
				s[i] = '1';y++;
			}else if(t>tar&&s[i]=='0'&&z<tar){
				s[i] = '2';z++;
			}
		}
	}else if(y>tar&&x<=tar&&z<=tar){
		int t=0;
		for(int i=0;i<n;i++){
			if(s[i]=='1'&&x<tar){
			s[i] = '0';x++;
		}
		if(s[i]=='1'&&x==tar)t++;
		if(t>tar&&s[i]=='1'&&z<tar){
			s[i] = '2';z++;
		}
		}
	}else if(z>tar&&y<=tar&&x<=tar){
		for(int i=0;i<n;i++){
			if(s[i]=='2'&&x<tar){
			s[i] = '0';x++;
		}else if(s[i]=='2'&&y<tar){
			s[i] = '1';y++;
		}
		}
	}else if(z>tar&&y>tar&&x<=tar){
		for(int i=0;i<n;i++){
			if((s[i]=='1'||s[i]=='2')&&x<tar){
				s[i]='0';x++;
			}
		}
	}else if(x>tar&&z>tar&&y<=tar){
		int t=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t++;
			if(s[i]=='0'&&t>tar&&y<tar){
				s[i] = '1';y++;
			}else if(s[i]=='2'&&y<tar){
				s[i] = '1';y++;
			}
		}
	}else if(x>tar&&y>tar&&z<=tar){
		int t0=0,t1=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t0++;
			if(s[i]=='1')t1++;
			if(s[i]=='0'&&t0>tar&&z<tar){
				s[i] = '2';z++;
			}
			if(s[i]=='1'&&t1>tar&&z<tar){
				s[i] = '2';z++;
			}
		}
	}
	cout<<s;
	return 0;
}


#include <bits/stdc++.h>
#define fill(x,c) memset(x,c,sizeof(x))
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const long long LL_INF = (long long) 2e18 + 5;
const int SIZE = 1e6+10;
ll n;
int a[SIZE];
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
	cin>>n;
	string s;cin>>s;ll tar = n/3,cnt=0;
	ll x=0,y=0,z=0;
	for(int i=0;i<n;i++){
		if(s[i]=='0')x++;
		if(s[i]=='1')y++;
		if(s[i]=='2')z++;
	}
	if(x==y&&y==z){
		cout<<s;return 0;
	}
	if(x>tar&&y<=tar&&z<=tar){
		int t = 0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t++;
			if(t>tar&&s[i]=='0'&&y<tar){
				s[i] = '1';y++;
			}else if(t>tar&&s[i]=='0'&&z<tar){
				s[i] = '2';z++;
			}
		}
	}else if(y>tar&&x<=tar&&z<=tar){
		int t=0;
		for(int i=0;i<n;i++){
			if(s[i]=='1'&&x<tar){
			s[i] = '0';x++;
		}
		if(s[i]=='1'&&x==tar)t++;
		if(t>tar&&s[i]=='1'&&z<tar){
			s[i] = '2';z++;
		}
		}
	}else if(z>tar&&y<=tar&&x<=tar){
		for(int i=0;i<n;i++){
			if(s[i]=='2'&&x<tar){
			s[i] = '0';x++;
		}else if(s[i]=='2'&&y<tar){
			s[i] = '1';y++;
		}
		}
	}else if(z>tar&&y>tar&&x<=tar){
		for(int i=0;i<n;i++){
			if((s[i]=='1'||s[i]=='2')&&x<tar){
				s[i]='0';x++;
			}
		}
	}else if(x>tar&&z>tar&&y<=tar){
		int t=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t++;
			if(s[i]=='0'&&t>tar&&y<tar){
				s[i] = '1';y++;
			}else if(s[i]=='2'&&y<tar){
				s[i] = '1';y++;
			}
		}
	}else if(x>tar&&y>tar&&z<=tar){
		int t0=0,t1=0;
		for(int i=0;i<n;i++){
			if(s[i]=='0')t0++;
			if(s[i]=='1')t1++;
			if(x>tar&&s[i]=='0'&&t0>tar&&z<tar){
				s[i] = '2';z++;x--;
			}
			if(y>tar&&s[i]=='1'&&t1>tar&&z<tar){
				s[i] = '2';z++;y--;
			}
		}
	}
	cout<<s;
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>

#define ll long long
#define PI 3.14159265
#define lp(n) for(int i= 0; i<(n) ; i++)
//#define all(v) (v.begin()), ((v.end()))
#define sz(v)   ((int)((v).size()))
//#define endl '\n'
//#define all(v) ((v).begin()), ((v).end())
//#define sz(v) ((int)((v).size()))
using namespace std;

vector<vector<int>> adj;

int main(){

    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("battery.in" , "r" , stdin) ;
    //freopen("xd.txt" , "w" , stdout) ;

    int n; cin>>n;
    bool visted[n];
    int arr[3]={0,0,0};
    char s[n];
    lp(n){
        cin>>s[i];
        if(s[i]=='0')
            arr[0]++;
        else if(s[i]=='1')
            arr[1]++;
        else
            arr[2]++;
    }

    for(int h=0; h<n&&arr[0]<n/3;h++){
        if(arr[s[h]-'0']>n/3&&2!=s[h]-'0'&&!visted[h]){
            arr[s[h]-'0']--;
            s[h]='0';
            visted[h]=1;
            arr[0]++;
        }
    }

    for(int h=n-1; h >=0&&arr[2]<n/3; h--){
            if(arr[s[h]-'0']>n/3&&2!=s[h]-'0'&&!visted[h]){
                visted[h]=1;
                arr[s[h]-'0']--;
                s[h]=2+'0';
                arr[2]++;
            }
        }

    for(int h=n-1; h >=0&&arr[1]<n/3; h--){
            if(arr[s[h]-'0']>n/3&&1!=s[h]-'0'&&!visted[h]){
                visted[h]=1;
                arr[s[h]-'0']--;
                s[h]=1+'0';
                arr[1]++;
                }
            }

    lp(n){
        cout<<s[i];
    }
}


#include <iostream>
#include <bits/stdc++.h>

#define ll long long
#define PI 3.14159265
#define lp(n) for(int i= 0; i<(n) ; i++)
//#define all(v) (v.begin()), ((v.end()))
#define sz(v)   ((int)((v).size()))
//#define endl '\n'
//#define all(v) ((v).begin()), ((v).end())
//#define sz(v) ((int)((v).size()))
using namespace std;

vector<vector<int>> adj;

int main(){

    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("battery.in" , "r" , stdin) ;
    //freopen("xd.txt" , "w" , stdout) ;

    int n; cin>>n;
    bool visted[n];
    lp(n){
        visted[i]=0;
    }
    int arr[3]={0,0,0};
    char s[n];
    lp(n){
        cin>>s[i];
        if(s[i]=='0')
            arr[0]++;
        else if(s[i]=='1')
            arr[1]++;
        else
            arr[2]++;
    }

    for(int h=0; h<n&&arr[0]<n/3;h++){
        if(arr[s[h]-'0']>n/3&&2!=s[h]-'0'&&!visted[h]){
            arr[s[h]-'0']--;
            s[h]='0';
            visted[h]=1;
            arr[0]++;
        }
    }

    for(int h=n-1; h >=0&&arr[2]<n/3; h--){
            if(arr[s[h]-'0']>n/3&&2!=s[h]-'0'&&!visted[h]){
                visted[h]=1;
                arr[s[h]-'0']--;
                s[h]=2+'0';
                arr[2]++;
            }
        }

    for(int h=n-1; h >=0&&arr[1]<n/3; h--){
            if(arr[s[h]-'0']>n/3&&1!=s[h]-'0'&&!visted[h]){
                visted[h]=1;
                arr[s[h]-'0']--;
                s[h]=1+'0';
                arr[1]++;
                }
            }

    lp(n){
        cout<<s[i];
    }
}


#include <iostream>
#include <bits/stdc++.h>

#define ll long long
#define PI 3.14159265
#define lp(n) for(int i= 0; i<(n) ; i++)
//#define all(v) (v.begin()), ((v.end()))
#define sz(v)   ((int)((v).size()))
//#define endl '\n'
//#define all(v) ((v).begin()), ((v).end())
//#define sz(v) ((int)((v).size()))
using namespace std;

vector<vector<int>> adj;

int main(){

    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("battery.in" , "r" , stdin) ;
    //freopen("xd.txt" , "w" , stdout) ;

    int n; cin>>n;
    bool visted[n];
    lp(n){
        visted[i]=0;
    }
    int arr[3]={0,0,0};
    char s[n];
    lp(n){
        cin>>s[i];
        if(s[i]=='0')
            arr[0]++;
        else if(s[i]=='1')
            arr[1]++;
        else
            arr[2]++;
    }

    for(int h=0; h<n&&arr[0]<n/3;h++){
        if(arr[s[h]-'0']>n/3&&0!=s[h]-'0'&&!visted[h]){
            arr[s[h]-'0']--;
            s[h]='0';
            visted[h]=1;
            arr[0]++;
        }
    }

    for(int h=n-1; h >=0&&arr[2]<n/3; h--){
            if(arr[s[h]-'0']>n/3&&2!=s[h]-'0'&&!visted[h]){
                visted[h]=1;
                arr[s[h]-'0']--;
                s[h]=2+'0';
                arr[2]++;
            }
        }

    for(int h=n-1; h >=0&&arr[1]<n/3; h--){
            if(arr[s[h]-'0']>n/3&&1!=s[h]-'0'&&!visted[h]){
                visted[h]=1;
                arr[s[h]-'0']--;
                s[h]=1+'0';
                arr[1]++;
                }
            }

    lp(n){
        cout<<s[i];
    }
}


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

const int N = 3e5+101;
char a[N];

int main()
{
    int len;
    int zero = 0, one = 0, two = 0;
    cin >> len;
    cin >> a;
    int len = strlen(a);
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = len/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans && zero > ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans && zero > ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    else if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans && one > ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
            if(a[i] == '1' && two < ans && one > ans)
            {
                a[i] = '2';
                two ++;
                one --;
            }
        }
    }
    else if(two > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '2')
            {
                if(zero < ans && two > ans)
                {
                    zero ++;
                    two --;
                    a[i] = '0';
                }
                else if(one < ans && two >ans)
                {
                    one ++;
                    two --;
                    a[i] = '1';
                }
            }
        }
    }
    cout << a <<endl;
    return 0;
}


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

const int N = 3e5+101;
char a[N];
bool vis[N] = {0};

int main()
{
    int n;
    int zero = 0, one = 0, two = 0;
    cin >> n;
    cin >> a;
    int len = strlen(a);
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = n/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans && zero > ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans &&zero > ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    else if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans && one > ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
                if(a[i] == '1' && two < ans && one > ans)
                {
                    a[i] = '2';
                    two ++;
                    one --;
                }
        }
    }
    else if(two > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '2' && zero < ans && two > ans)
            {
                zero ++;
                two --;
                a[i] = '0';
            }
            else if(a[i] == '2' && one < ans && two >ans)
            {
                one ++;
                two --;
                a[i] = '1';
            }
        }
    }
    cout << a <<endl;
    return 0;
}


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

const int N = 3e5+101;
char a[N];

int main()
{
    int n;
    int zero = 0, one = 0, two = 0;
    cin >> n;
    cin >> a;
    int len = strlen(a);
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = len/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans && zero > ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans && zero > ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    else if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans && one > ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
                if(a[i] == '1' && two < ans && one > ans)
                {
                    a[i] = '2';
                    two ++;
                    one --;
                }
        }
    }
    else if(two > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '2' && zero < ans && two > ans)
            {
                zero ++;
                two --;
                a[i] = '0';
            }
            else if(a[i] == '2' && one < ans && two >ans)
            {
                one ++;
                two --;
                a[i] = '1';
            }
        }
    }
    cout << a <<endl;
    return 0;
}


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

const int N = 3e5+101;
char a[N];

int main()
{
    int len;
    int zero = 0, one = 0, two = 0;
    cin >> len;
    cin >> a;
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = len/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans && zero > ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans && zero > ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans && one > ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
            if(a[i] == '1' && two < ans && one > ans)
            {
                a[i] = '2';
                two ++;
                one --;
            }
        }
    }
    if(two > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '2')
            {
                if(zero < ans && two > ans)
                {
                    zero ++;
                    two --;
                    a[i] = '0';
                }
                else if(one < ans && two >ans)
                {
                    one ++;
                    two --;
                    a[i] = '1';
                }
            }
        }
    }
    cout << a <<endl;
    return 0;
}


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

const int N = 3e5+101;
char a[N];
bool vis[N] = {0};

int main()
{
    int n;
    int zero = 0, one = 0, two = 0;
    cin >> n;
    cin >> a;
    int len = strlen(a);
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = n/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    else if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
                if(a[i] == '1' && two < ans)
                {
                    a[i] = '2';
                    two ++;
                    zero --;
                }
        }
    }
    else if(two > ans)
    {
        for(int i = 0; i<len; i ++)
        {
            if(a[i] == '2' && zero < ans)
            {
                zero ++;
                two --;
                a[i] = '0';
            }
            else if(a[i] == '2' && one < ans)
            {
                one ++;
                two --;
                a[i] = '1';
            }
        }
    }
    cout << a <<endl;
    return 0;
}


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

const int N = 3e5+101;
char a[N];

int main()
{
    int len;
    int zero = 0, one = 0, two = 0;
    cin >> len;
    cin >> a;
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = len/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans && zero > ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans && zero > ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    else if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans && one > ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
            if(a[i] == '1' && two < ans && one > ans)
            {
                a[i] = '2';
                two ++;
                one --;
            }
        }
    }
    else if(two > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '2')
            {
                if(zero < ans && two > ans)
                {
                    zero ++;
                    two --;
                    a[i] = '0';
                }
                else if(one < ans && two >ans)
                {
                    one ++;
                    two --;
                    a[i] = '1';
                }
            }
        }
    }
    cout << a <<endl;
    return 0;
}


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

const int N = 3e5+101;
char a[N];
bool vis[N] = {0};

int main()
{
    int n;
    int zero = 0, one = 0, two = 0;
    cin >> n;
    cin >> a;
    int len = strlen(a);
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = n/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    else if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
                if(a[i] == '1' && two < ans)
                {
                    a[i] = '2';
                    two ++;
                    one --;
                }
        }
    }
    else if(two > ans)
    {
        for(int i = 0; i<len; i ++)
        {
            if(a[i] == '2' && zero < ans)
            {
                zero ++;
                two --;
                a[i] = '0';
            }
            else if(a[i] == '2' && one < ans)
            {
                one ++;
                two --;
                a[i] = '1';
            }
        }
    }
    cout << a <<endl;
    return 0;
}


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

const int N = 3e5+101;
char a[N];

int main()
{
    int n;
    int zero = 0, one = 0, two = 0;
    cin >> n;
    cin >> a;
    int len = strlen(a);
    for(int i = 0; i < len; i ++)
    {
        if(a[i] == '0')
        {
            zero ++;
        }
        else if(a[i] == '1')
        {
            one ++;
        }
        else if(a[i] == '2')
        {
            two ++;
        }
    }
    int ans = n/3;
    if(ans == one && ans == two && ans == zero)
    {
        cout << a <<endl;
        return 0;
    }
    if(zero > ans)
    {
        for(int i = len-1; i >= 0; i --)
        {
            if(a[i] == '0' && two < ans && zero > ans)
            {
                two ++;
                zero --;
                a[i] = '2';
            }
            else if(a[i] == '0' && one < ans && zero > ans)
            {
                one ++;
                zero --;
                a[i] = '1';
            }
        }
    }
    else if(one > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '1')
            {
                if(a[i] == '1' && zero < ans && one > ans)
                {
                    zero ++;
                    one --;
                    a[i] ='0';
                }
            }
        }
        for(int i = len-1; i>=0; i--)
        {
                if(a[i] == '1' && two < ans && one > ans)
                {
                    a[i] = '2';
                    two ++;
                    one --;
                }
        }
    }
    else if(two > ans)
    {
        for(int i = 0; i < len; i ++)
        {
            if(a[i] == '2' && zero < ans && two > ans)
            {
                zero ++;
                two --;
                a[i] = '0';
            }
            else if(a[i] == '2' && one < ans && two >ans)
            {
                one ++;
                two --;
                a[i] = '1';
            }
        }
    }
    cout << a <<endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll unsigned long long int

using namespace std;

int main()
{
    iostream::sync_with_stdio(false);
    cin.tie(0);
   ll N;
   cin >> N;
   string s;
   cin >> s;
   ll zero=0,one=0,two=0;
   for(ll i=0;i<N;i++){
    if(s[i]=='0'){
        zero++;
    }
    if(s[i]=='1'){
        one++;
    }
    if(s[i]=='2'){
        two++;
    }
   }
   if(zero==one && zero==two){
    cout << s; return 0;
}
for(ll i=0;i<N;i++){
    if(zero<N/3){
       if(two>N/3 && one>N/3){
        if(s.find('1')<s.find('2')){
            s[s.find('1')]='0';
            one--;
            zero++;
        }else{
        s[s.find('2')]='0';
        two--;
        zero++;
        }
       }else if(two>N/3 && zero<N/3){
    s[s.find('2')]='0';
    two--;zero++;
    }else if(one>N/3 && zero<N/3){
    s[s.find('1')]='0';
    one--;zero++;
    }
    }else{
    break;}
}
if(zero==one && zero==two){
    cout << s; return 0;
}
for(ll i=0;i<N;i++){
    if(two<N/3){
       if(zero>N/3 && one>N/3){
        if(s.find_last_of('1')>s.find_last_of('0')){
            s[s.find_last_of('1')]='2';
            one--;
            two++;
        }else{
        s[s.find_last_of('0')]='2';
        two++;
        zero--;
        }
       }else if(zero>N/3){
       s[s.find_last_of('0')]='2';
        two++;
        zero--;
       }else if(one>N/3){
       s[s.find_last_of('1')]='2';
            one--;
            two++;
       }

    }else{
    break;}
}
if(zero==one && zero==two){
    cout << s; return 0;
}
for(ll i=0;i<N;i++){
    if(one<N/3){
        if(two>N/3 && zero>N/3){
            if((s.find_last_of('0'))>(s.find('2'))){
                s[s.find_last_of('0')]='1';
                one++;zero--;
            }else{
            s[s.find('2')]='1';
            two--;one++;
            }
        }else if(zero>N/3){
        s[s.find_last_of('0')]='1';
        zero--;one++;
        }else if(two>N/3){
            s[s.find('2')]='1';
            one++;two--;
        }
    }else{
    break;
    }
}
if(zero==one && zero==two){
    cout << s; return 0;
}
cout << s;

}

//5*(5+1)/2


#include <bits/stdc++.h>
#define ll unsigned long long int

using namespace std;

int main()
{
   ll N;
   cin >> N;
   string s;
   cin >> s;
   ll zero=0,one=0,two=0;
   for(ll i=0;i<N;i++){
    if(s[i]=='0'){
        zero++;
    }
    if(s[i]=='1'){
        one++;
    }
    if(s[i]=='2'){
        two++;
    }
   }
for(ll i=0;i<N;i++){
    if(s[i]=='0'){
        if(two<N/3){
            s[i]='2';
            two++;
            zero--;
        }else if(one<N/3){
        s[i]='1';
        one++;
        zero--;
        }
    }else if(s[i]=='1'){
        if(two<N/3){
            s[i]='2';
            two++;
            one--;
        }else if(zero<N/3){
        s[i]='0';
        one--;
        zero++;
        }
    }else if(s[i]=='2'){
        if(one<N/3){
            s[i]='1';
            two--;
            one++;
        }else if(zero<N/3){
        s[i]='0';
        two--;
        zero++;
        }
    }
}
cout << s;

}

//5*(5+1)/2


#include <bits/stdc++.h>
#define ll unsigned long long int

using namespace std;

int main()
{
    iostream::sync_with_stdio(false);
    cin.tie(0);
   ll N;
   cin >> N;
   string s;
   cin >> s;
   ll zero=0,one=0,two=0;
   for(ll i=0;i<N;i++){
    if(s[i]=='0'){
        zero++;
    }else if(s[i]=='1'){
        one++;
    }else{
        two++;
    }
   }

    while(zero<N/3){
       if(two>N/3 && one>N/3){
        if(s.find('1')<s.find('2')){
            s[s.find('1')]='0';
            one--;
            zero++;
        }else{
        s[s.find('2')]='0';
        two--;
        zero++;
        }
       }else if(two>N/3 && zero<N/3){
    s[s.find('2')]='0';
    two--;zero++;
    }else if(one>N/3 && zero<N/3){
    s[s.find('1')]='0';
    one--;zero++;
    }
    }
    while(two<N/3){
       if(zero>N/3 && one>N/3){
        if(s.find_last_of('1')>s.find_last_of('0')){
            s[s.find_last_of('1')]='2';
            one--;
            two++;
        }else{
        s[s.find_last_of('0')]='2';
        two++;
        zero--;
        }
       }else if(zero>N/3){
       s[s.find_last_of('0')]='2';
        two++;
        zero--;
       }else if(one>N/3){
       s[s.find_last_of('1')]='2';
            one--;
            two++;
       }

    }
    while(one<N/3){
        if(two>N/3 && zero>N/3){
            if((s.find_last_of('0'))>(s.find('2'))){
                s[s.find_last_of('0')]='1';
                one++;zero--;
            }else{
            s[s.find('2')]='1';
            two--;one++;
            }
        }else if(zero>N/3){
        s[s.find_last_of('0')]='1';
        zero--;one++;
        }else if(two>N/3){
            s[s.find('2')]='1';
            one++;two--;
        }
    }

cout << s;

}

//5*(5+1)/2


#include <bits/stdc++.h>
#define ll unsigned long long int

using namespace std;

int main()
{
    iostream::sync_with_stdio(false);
    cin.tie(0);
   ll N;
   cin >> N;
   string s;
   cin >> s;
   ll zero=0,one=0,two=0;
   for(ll i=0;i<N;i++){
    if(s[i]=='0'){
        zero++;
    }else if(s[i]=='1'){
        one++;
    }else{
        two++;
    }
   }

if(zero<N/3){
    for(ll i=0;i<N;i++){
     if(s[i]=='2' && two>N/3){
            s[i]='0';
        zero++;two--;
     }else if(s[i]=='1' && one>N/3){
         s[i]='0';
     zero++;one--;
     }
     if(zero==N/3){
        break;
     }
    }
}
if(two<N/3){
    for(ll i=N-1;i>=0;i--){
        if(s[i]=='0' && zero>N/3){
            zero--;two++;
            s[i]='2';
        }else if(s[i]=='1' && one>N/3){
            s[i]='2';
        one--;two++;
        }
        if(two==N/3){
            break;
        }
    }
}
if(one<N/3){
    if(two>N/3){
        for(ll i=0;i<N;i++){
            if(s[i]=='2'){
                s[i]='1';
                two--;one++;
            }
            if(one==N/3){
                break;
            }
        }
    }else{
     for(ll i=N-1;i>=0;i--){
            if(s[i]=='0'){
                s[i]='1';
                zero--;one++;
            }
            if(one==N/3){
                break;
            }
        }
    }

}

cout << s;

}

//5*(5+1)/2


#include <bits/stdc++.h>
#define ll unsigned long long int

using namespace std;

int main()
{
    iostream::sync_with_stdio(false);
    cin.tie(0);
   ll N;
   cin >> N;
   string s;
   cin >> s;
   ll zero=0,one=0,two=0;
   for(ll i=0;i<N;i++){
    if(s[i]=='0'){
        zero++;
    }else if(s[i]=='1'){
        one++;
    }else{
        two++;
    }
   }

if(zero<N/3){
    for(ll i=0;i<N;i++){
     if(s[i]=='2' && two>N/3){
            s[i]='0';
        zero++;two--;
     }else{
         s[i]='0';
     zero++;one--;
     }
     if(zero==N/3){
        break;
     }
    }
}
if(two<N/3){
    for(ll i=N-1;i>=0;i--){
        if(s[i]=='0' && zero>N/3){
            zero--;two++;
            s[i]='2';
        }else{
            s[i]='2';
        one--;two++;
        }
        if(two==N/3){
            break;
        }
    }
}
if(one<N/3){
    if(two>N/3){
        for(ll i=0;i<N;i++){
            if(s[i]=='2'){
                s[i]=='1';
                two--;one++;
            }
            if(one==N/3){
                break;
            }
        }
    }else{
     for(ll i=N-1;i>=0;i--){
            if(s[i]=='0'){
                s[i]='1';
                zero--;one++;
            }
            if(one==N/3){
                break;
            }
        }
    }

}

cout << s;

}

//5*(5+1)/2