#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c,tmp;
map<ll,ll>m;
map<ll,ll>::iterator it;

set<ll>s;
ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(s.size()==1){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;
        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        s.insert(x);
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
     v=vector<ll>(s.begin() ,s.end());
    ///for(auto ip:v) cout<<ip<<" .,"; eee;
     if(n==1 || n==2) ret spcase(),0;
    /// c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] ) ; i=-1; /*cout<<c.back()<<"<-Insertd "; */  }
        if((c.size() ) == lmt*lmt ) break;
    }

   /// cout<<" XCZ "<<c.size()<<endl;
    if((c.size() ) < lmt*lmt ) { cout<<"NO\n";
            ret 0;}
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size() ; i++)
        {
              cur=c.back(), c.pop_back(); //tmp.pop_back() ;
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }
        ///cout<<"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               //cout<<v[i]<<" |_--_| "<<m[v[i] ]<<endl;
               tmp.pb(v[i]);
               i=-1;
           }
           if(tmp.size()*2 == n-1) break;
        }
        /////cout<<"XXXXXXX  "<<tmp.size()<<endl;;
        ///for(auto iy:tmp) cout<<iy<<" XX4";
        if(tmp.size()*2 < n-1) {cout<<"NO\n";
            ret 0;}
        for(ll i=1; i<=lmt  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               //cout<<v[i]<<" |_--_| "<<m[v[i] ]<<endl;
               tmp.pb(v[i]);
               i=-1;
           }
           if(tmp.size()*2 == n-1) break;
        }
        //cout<<tmp.size()<<" SIZZZZ \n";
        if(tmp.size()*2 < n-1) {cout<<"NO\n";
            ret 0;}
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]==1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0 || sps.size()>1 )
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
//    loopeq(i,1,n)
//    {
//        loopeq(j,1,n)
//        {
//           if(ans[i][j]==-1 || ans[i][j]>mx)
//           {
//               cout<<"NO\n";
//            ret 0;
//           }
//        }
//
//    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
5
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c,tmp;
map<ll,ll>m;
map<ll,ll>::iterator it;

set<ll>s;
ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(s.size()==1){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;
        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        s.insert(x);
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
     v=vector<ll>(s.begin() ,s.end());
    ///for(auto ip:v) cout<<ip<<" .,"; eee;
     if(n==1 || n==2) ret spcase(),0;
    /// c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] ) ; i=0; /*cout<<c.back()<<"<-Insertd "; */  }
        if((c.size() ) == lmt*lmt ) break;
    }

    cout<<" XCZ "<<c.size()<<endl;
    if((c.size() ) < lmt*lmt ) { cout<<"NO\n";
            ret 0;}
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size() ; i++)
        {
              cur=c.back(), c.pop_back(); //tmp.pop_back() ;
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }
        ///cout<<"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               //cout<<v[i]<<" |_--_| "<<m[v[i] ]<<endl;
               tmp.pb(v[i]);
               i=0;
           }
           if(tmp.size()*2 == n-1) break;
        }
        /////cout<<"XXXXXXX  "<<tmp.size()<<endl;;
        ///for(auto iy:tmp) cout<<iy<<" XX4";
        if(tmp.size()*2 < n-1) {cout<<"NO\n";
            ret 0;}
        for(ll i=1; i<=lmt and tmp.size()  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }
        tmp.clear();
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               //cout<<v[i]<<" |_--_| "<<m[v[i] ]<<endl;
               tmp.pb(v[i]);
               i=0;
           }
           if(tmp.size()*2 == n-1) break;
        }
        //cout<<tmp.size()<<" SIZZZZ \n";
        if(tmp.size()*2 < n-1) {cout<<"NO\n";
            ret 0;}
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]==1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0 )
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
           if(ans[i][j]==-1 || ans[i][j]>mx)
           {
               cout<<"NO\n";
            ret 0;
           }
        }

    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c;
map<ll,ll>m;
map<ll,ll>::iterator it;

ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(v[0]==v[3]){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;

        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
    auto ip=unique(v.begin() ,v.end() );
    v.resize(  distance(v.begin() , ip) );

    ///for(auto ip:v) cout<<ip<<" .,"; eee;

     if(n==1 || n==2) ret spcase(),0;
    /// c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] );  i=0; /*cout<<c.back()<<"<-Insertd "; */  }
        if((c.size() ) ==lmt*lmt ) break;
    }
//     cout<<" \n::::::::: "<<c.size()<<" elements: ";
//    for(auto it2:c) cout<<it2<<" ";
//    eee;
    if( (c.size() ) !=lmt*lmt)   {cout<<"NO\n"; ret 0; }
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size() ; i++)
        {
              cur=c.back(); c.pop_back();
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        vector<ll>tmp;
        ///tmp=c;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
          if((2*tmp.size() +1 ) ==n ) break;
        }
        ///cout<<tmp.size()<<" TMP "<<endl;
        if((2*tmp.size() +1 ) !=n  )   {cout<<"NO\n"; ret 0; }

        for(ll i=1; i<=lmt  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }
        tmp.clear() ;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
         if((2*tmp.size() +1 ) ==n ) break;

        }
        if((2*tmp.size() +1 ) !=n  )   {cout<<"NO\n"; ret 0; }
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0 )
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
           if(ans[i][j]==-1 || ans[i][j]>mx)
           {
               cout<<"NO\n";
            ret 0;
           }
        }

    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c;
map<ll,ll>m;
map<ll,ll>::iterator it;

set<ll>s;
ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(v[0]==v[3]){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;

        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        s.insert(x);
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
     v=vector<ll>(s.begin() ,s.end());
    ///for(auto ip:v) cout<<ip<<" .,"; eee;

     if(n==1 || n==2) ret spcase(),0;
    /// c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] );  i=0; /*cout<<c.back()<<"<-Insertd "; */  }
        /////if((c.size() ) ==lmt*lmt ) break;
    }
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size() ; i++)
        {
              cur=c.back(), c.pop_back();
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        vector<ll>tmp=c;
        ///tmp=c;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
        }
        for(ll i=1; i<=lmt  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
        }
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]==1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0 )
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
           if(ans[i][j]==-1 || ans[i][j]>mx)
           {
               cout<<"NO\n";
            ret 0;
           }
        }

    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c;
map<ll,ll>m;
map<ll,ll>::iterator it;

ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(v[0]==v[3]){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;

        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
    auto ip=unique(v.begin() ,v.end() );
    v.resize(  distance(v.begin() , ip) );

    ///for(auto ip:v) cout<<ip<<" .,"; eee;

     if(n==1 || n==2) ret spcase(),0;
     c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] );  i=0; /*cout<<c.back()<<"<-Insertd "; */  }
        if((c.size()  -1) ==lmt*lmt ) break;
    }
//     cout<<" \n::::::::: "<<c.size()<<" elements: ";
//    for(auto it2:c) cout<<it2<<" ";
//    eee;
    if( (c.size()  -1) !=lmt*lmt)   {cout<<"NO\n"; ret 0; }
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size()>1 ; i++)
        {
              cur=c.back(); c.pop_back();
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }

        /////////////////////////////////
//        loopeq(i,1,n)
//        {
//            loopeq(j,1,n)
//            {
//                cout<<ans[i][j]<<" ";
//            }
//            eee;
//
//        }
    ////////////////////////////////////
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        vector<ll>tmp;
        ///tmp=c;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
           }
        }
//        if(  2*tmp.size()+1 !=n )
//        {
//            cout<<"NO\n";
//            ret 0;
//        }
        ///cout<<tmp.size()<<" TMP "<<endl;
        for(ll i=1; i<=lmt  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }

        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
           }
        }
//        if(  2*tmp.size()+1 !=n )
//        {
//            cout<<"NO\n";
//            ret 0;
//        }
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0)
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
           if(ans[i][j]<1 || ans[i][j]>mx)
           {
               cout<<"NO\n";
            ret 0;
           }
        }
        ///eee;

    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c;
map<ll,ll>m;
map<ll,ll>::iterator it;

ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(v[0]==v[3]){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;

        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
    auto ip=unique(v.begin() ,v.end() );
    v.resize(  distance(v.begin() , ip) );

    ///for(auto ip:v) cout<<ip<<" .,"; eee;

     if(n==1 || n==2) ret spcase(),0;
     c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] );  i=0; /*cout<<c.back()<<"<-Insertd "; */  }
        if((c.size()  -1) ==lmt*lmt ) break;
    }
//     cout<<" \n::::::::: "<<c.size()<<" elements: ";
//    for(auto it2:c) cout<<it2<<" ";
//    eee;
    if( (c.size()  -1) !=lmt*lmt)   {cout<<"NO\n"; ret 0; }
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size()>1 ; i++)
        {
              cur=c.back(); c.pop_back();
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        vector<ll>tmp;
        ///tmp=c;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
        }
        ///cout<<tmp.size()<<" TMP "<<endl;
        for(ll i=1; i<=lmt  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }

        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
        }
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0)
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
           if(ans[i][j]==-1 || ans[i][j]>mx)
           {
               cout<<"NO\n";
            ret 0;
           }
        }

    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c,tmp;
map<ll,ll>m;
map<ll,ll>::iterator it;

set<ll>s;
ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(v[0]==v[3]){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;
        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        s.insert(x);
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
     v=vector<ll>(s.begin() ,s.end());
    ///for(auto ip:v) cout<<ip<<" .,"; eee;
     if(n==1 || n==2) ret spcase(),0;
    /// c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] ) ; i=0; /*cout<<c.back()<<"<-Insertd "; */  }
        if((c.size() ) == lmt*lmt ) break;
    }
    if((c.size() ) < lmt*lmt ) { cout<<"NO\n";
            ret 0;}
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size() ; i++)
        {
              cur=c.back(), c.pop_back(); //tmp.pop_back() ;
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }
        ///cout<<"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               //cout<<v[i]<<" |_--_| "<<m[v[i] ]<<endl;
               tmp.pb(v[i]);
               i=0;
           }
           if(tmp.size()*2 == n-1) break;
        }
        /////cout<<"XXXXXXX  "<<tmp.size()<<endl;;
        ///for(auto iy:tmp) cout<<iy<<" XX4";
        if(tmp.size()*2 < n-1) {cout<<"NO\n";
            ret 0;}
        for(ll i=1; i<=lmt and tmp.size()  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }
        tmp.clear();
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               //cout<<v[i]<<" |_--_| "<<m[v[i] ]<<endl;
               tmp.pb(v[i]);
               i=0;
           }
           if(tmp.size()*2 == n-1) break;
        }
        //cout<<tmp.size()<<" SIZZZZ \n";
        if(tmp.size()*2 < n-1) {cout<<"NO\n";
            ret 0;}
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]==1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0 )
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
           if(ans[i][j]==-1 || ans[i][j]>mx)
           {
               cout<<"NO\n";
            ret 0;
           }
        }

    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,l,u) for(int i=(int)l ; i<(int)u  ; i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define pb push_back
#define ret return
#define sc second
#define fs first

#define eee cout<<endl;
ll n,lmt,x,mx=-9;
vector<ll>v,c;
map<ll,ll>m;
map<ll,ll>::iterator it;

ll ans[23][23];
ll spcase()
{
     if(n==1)
    {
        ret cout<<"YES\n"<<v[0]<<endl,0;
    }
    if(n==2)
    {
        sort(v.begin(),v.end() );
        if(v[0]==v[3]){
                cout<<"YES\n"<<v[0]<<" "<<v[0]<<"\n"<<v[0]<<" "<<v[0];
                ret 0;

        }
        else cout<<"NO\n";
    }
}
int main()
{
    cin>>n;
    memset(ans,-1,sizeof ans);
    loop(i,0,n*n)
    {
        cin>>x;
        v.pb(x);
        mx=max(mx,x);
        m[x]++;
        ///cout<<"x= "<<x<<" m[x]= "<<m[x]<<endl;
    }
    lmt=n/2;
    sort(v.begin(),v.end());
    auto ip=unique(v.begin() ,v.end() );
    v.resize(  distance(v.begin() , ip) );

    ///for(auto ip:v) cout<<ip<<" .,"; eee;

     if(n==1 || n==2) ret spcase(),0;
    /// c.pb(-1);
    for(ll i=0 ; i<v.size() ; i++)
    {
        if( m[ v[i] ] >=4) {  m[ v[i] ] = m[ v[i] ] -4  ; c.pb( v[i] );  i=0; /*cout<<c.back()<<"<-Insertd "; */  }
        if((c.size() ) ==lmt*lmt ) break;
    }
//     cout<<" \n::::::::: "<<c.size()<<" elements: ";
//    for(auto it2:c) cout<<it2<<" ";
//    eee;
    if( (c.size() ) !=lmt*lmt)   {cout<<"NO\n"; ret 0; }
    {
        ll ex=0,ccc=0,r=1,tr=1,cur;
        ///reverse(  c.begin() , c.end() );c.pop_back() ; size tik koro;
        for(ll i=1 ;c.size() ; i++)
        {
              cur=c.back(); c.pop_back();
              if( i%(lmt+1)==0 ) {r++; i=1 ; }
              ans[r][i]= ans[r][n-i+1]=cur;
              ans[n-r+1][i] = ans[n-r+1] [  n-i+1] =cur;
        }
    }
    vector<ll>sps;
    if(n%2)
    {
        ll r=lmt+1 , col=lmt+1;
        vector<ll>tmp;
        ///tmp=c;
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
        if((2*tmp.size() +1 ) ==n ) break;
        }
        ///cout<<tmp.size()<<" TMP "<<endl;
        for(ll i=1; i<=lmt  ; i++)
        {
            ans[r][i]= ans[r][n-i+1]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=2 )
           {
               m[ v[i] ] =m[ v[i ] ]-2;
               tmp.pb(v[i]);
               i=0;
           }
            if((2*tmp.size() +1 ) ==n ) break;

        }
        for(ll i=1; i<=lmt ; i++)
        {
            ans[i][col]= ans[ n-i+1 ][  col ]=tmp.back();
            tmp.pop_back() ;
        }
        for(ll i=0 ; i<v.size() ; i++)
        {
           if( m[ v[i]  ]>=1 )
           {
               sps.pb(v[i]);
           }
        }
        if(sps.size()==0)
        {
            cout<<"NO\n";
            ret 0;
        }
        ans[lmt+1][lmt+1]=sps.back() ;
    }
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
           if(ans[i][j]==-1 || ans[i][j]>mx)
           {
               cout<<"NO\n";
            ret 0;
           }
        }

    }
    cout<<"YES\n";
    loopeq(i,1,n)
    {
        loopeq(j,1,n)
        {
            cout<<ans[i][j]<<" ";
        }
        eee;

    }

}
/*
7
5 9 5 4 1 9 8 4 5 1 4 10 7 7 8 4 2 4 4 5 4 4 10 3 4 6 8 1 9 9 5 6 8 7 1 8 6 6 7 5 3 1 1 4 7 2 3 3 8
*/


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],res[300][300];
map<int,int> mp;
vector<int> vec;
int main(){
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n*n;i++){
        if(!mp[a[i]]){
            vec.push_back(a[i]);
        }
        mp[a[i]]++;
    }
    //odd
    if(n&1){
        int t=0;
        int duijiao;
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                if(t>0){cout<<"NO"<<endl; return 0;}
                duijiao=vec[i];
                mp[vec[i]]--;
                t++;
            }
            //if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
        vector<int> cnt;
        int s=0,bod=(n/2)*(n/2);
        for(int i=0;i<vec.size();i++){
            if(s>=bod) break;
            while(mp[vec[i]]>=4){
                mp[vec[i]]-=4;
                cnt.push_back(vec[i]);
                if(++s==bod) break;
            }
        }
        if(s<bod){cout<<"NO"<<endl; return 0;}
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        for(int i=0;i<vec.size();i++){
            while(mp[vec[i]]){
                mp[vec[i]]-=2;
                cnt.push_back(vec[i]);
            }
        }

        int idx=0;
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                res[i][j]=res[j][n+1-i]=res[n+1-j][i]=res[n+1-i][n+1-j]=cnt[idx++];

            }
        }
        res[(n+1)/2][(n+1)/2]=duijiao;
        for(int i=1;i<=n/2;i++) res[i][(n+1)/2]=res[n+1-i][(n+1)/2]=cnt[idx++];
        for(int j=1;j<=n/2;j++) res[(n+1)/2][j]=res[(n+1)/2][n+1-j]=cnt[idx++];
    }else{ //even
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                cout<<"NO"<<endl; return 0;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
                vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        int idx=0;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                    //cout<<"i="<<i<<" j="<<j<<" "<<"idx="<<idx<<" "<<vec[idx]<<endl;
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],res[300][300];
map<int,int> mp;
vector<int> vec;
int main(){
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n*n;i++){
        if(!mp[a[i]]){
            vec.push_back(a[i]);
        }
        mp[a[i]]++;
    }
    //odd
    if(n&1){
        int t=0;
        int duijiao;
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                if(t>0){cout<<"NO"<<endl; return 0;}
                duijiao=vec[i];
                mp[vec[i]]--;
                t++;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
        vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            //cout<<"vec[i]="<<vec[i]<<"mp="<<mp[vec[i]]<<endl;
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }

        int idx=0;
//        for(int i=1;i<=n-1;i++){
//            for(int j=1;j<=n-i;j++){
//                res[i][j]=res[n+1-i][n+1-j]=cnt[idx++];
//            }
//        }
//        for(int i=1;i<=n/2;i++){
//            res[i][n+1-i]=res[n+1-i][i]=cnt[idx++];
//        }
//        res[(n+1)/2][(n+1)/2]=duijiao;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=(n+1)/2;j++){

                if(j==(n+1)/2) res[i][j]=res[n+1-i][j]=res[j][i]=res[j][n+1-i]=cnt[idx++];
                else res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];

            }
        }
        res[(n+1)/2][(n+1)/2]=duijiao;
    }else{ //even
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                cout<<"NO"<<endl; return 0;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
                vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }
        for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        int idx=0;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                    //cout<<"i="<<i<<" j="<<j<<" "<<"idx="<<idx<<" "<<vec[idx]<<endl;
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],res[300][300];
map<int,int> mp;
vector<int> vec;
int main(){
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n*n;i++){
        if(!mp[a[i]]){
            vec.push_back(a[i]);
        }
        mp[a[i]]++;
    }
    //odd
    if(n&1){
        int t=0;
        int duijiao;
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                if(t>0){cout<<"NO"<<endl; return 0;}
                duijiao=vec[i];
                mp[vec[i]]--;
                t++;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
        vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            //cout<<"vec[i]="<<vec[i]<<"mp="<<mp[vec[i]]<<endl;
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }

        int idx=0;
//        for(int i=1;i<=n-1;i++){
//            for(int j=1;j<=n-i;j++){
//                res[i][j]=res[n+1-i][n+1-j]=cnt[idx++];
//            }
//        }
//        for(int i=1;i<=n/2;i++){
//            res[i][n+1-i]=res[n+1-i][i]=cnt[idx++];
//        }
//        res[(n+1)/2][(n+1)/2]=duijiao;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=(n+1)/2;j++){

                if(j==(n+1)/2) res[i][j]=res[n+1-i][j]=res[j][i]=res[j][n+1-i]=cnt[idx++];
                else res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];

            }
        }
        res[(n+1)/2][(n+1)/2]=duijiao;
    }else{ //even
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                cout<<"NO"<<endl; return 0;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
                vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        int idx=0;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                    //cout<<"i="<<i<<" j="<<j<<" "<<"idx="<<idx<<" "<<vec[idx]<<endl;
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],res[300][300];
map<int,int> mp;
vector<int> vec;
int main(){
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n*n;i++){
        if(!mp[a[i]]){
            vec.push_back(a[i]);
        }
        mp[a[i]]++;
    }
    //odd
    if(n&1){
        int t=0;
        int duijiao;
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                if(t>0){cout<<"NO"<<endl; return 0;}
                duijiao=vec[i];
                mp[vec[i]]--;
                t++;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
        vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            //cout<<"vec[i]="<<vec[i]<<"mp="<<mp[vec[i]]<<endl;
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }

        int idx=0;
//        for(int i=1;i<=n-1;i++){
//            for(int j=1;j<=n-i;j++){
//                res[i][j]=res[n+1-i][n+1-j]=cnt[idx++];
//            }
//        }
//        for(int i=1;i<=n/2;i++){
//            res[i][n+1-i]=res[n+1-i][i]=cnt[idx++];
//        }
//        res[(n+1)/2][(n+1)/2]=duijiao;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=(n+1)/2;j++){
                if(j==(n+1)/2) res[i][j]=res[n+1-j][i]=res[j][i]=res[j][n+1-i]=cnt[idx++];
                else res[i][j]=res[j][n+1-i]=res[n+1-j][i]=res[n+1-i][n+1-j]=cnt[idx++];

            }
        }
        res[(n+1)/2][(n+1)/2]=duijiao;
    }else{ //even
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                cout<<"NO"<<endl; return 0;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
                vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        int idx=0;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                    //cout<<"i="<<i<<" j="<<j<<" "<<"idx="<<idx<<" "<<vec[idx]<<endl;
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],res[300][300];
map<int,int> mp;
vector<int> vec;
int main(){
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n*n;i++){
        if(!mp[a[i]]){
            vec.push_back(a[i]);
        }
        mp[a[i]]++;
    }
    //odd
    if(n&1){
        int t=0;
        int duijiao;
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                if(t>0){cout<<"NO"<<endl; return 0;}
                duijiao=vec[i];
                mp[vec[i]]--;
                t++;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
        vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            //cout<<"vec[i]="<<vec[i]<<"mp="<<mp[vec[i]]<<endl;
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }

        int idx=0;
//        for(int i=1;i<=n-1;i++){
//            for(int j=1;j<=n-i;j++){
//                res[i][j]=res[n+1-i][n+1-j]=cnt[idx++];
//            }
//        }
//        for(int i=1;i<=n/2;i++){
//            res[i][n+1-i]=res[n+1-i][i]=cnt[idx++];
//        }
//        res[(n+1)/2][(n+1)/2]=duijiao;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=(n+1)/2;j++){
                //if(j==(n+1)/2) res[i][j]=res[n+1-j][i]=res[j][i]=res[j][n+1-i]=cnt[idx++];
                res[i][j]=res[j][n+1-i]=res[n+1-j][i]=res[n+1-i][n+1-j]=cnt[idx++];

            }
        }
        res[(n+1)/2][(n+1)/2]=duijiao;
    }else{ //even
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                cout<<"NO"<<endl; return 0;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
                vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        int idx=0;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                    //cout<<"i="<<i<<" j="<<j<<" "<<"idx="<<idx<<" "<<vec[idx]<<endl;
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],res[300][300];
map<int,int> mp;
vector<int> vec;
int main(){
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n*n;i++){
        if(!mp[a[i]]){
            vec.push_back(a[i]);
        }
        mp[a[i]]++;
    }
    //odd
    if(n&1){
        int t=0;
        int duijiao;
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                if(t>0){cout<<"NO"<<endl; return 0;}
                duijiao=vec[i];
                mp[vec[i]]--;
                t++;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
        vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            //cout<<"vec[i]="<<vec[i]<<"mp="<<mp[vec[i]]<<endl;
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }

        int idx=0;
//        for(int i=1;i<=n-1;i++){
//            for(int j=1;j<=n-i;j++){
//                res[i][j]=res[n+1-i][n+1-j]=cnt[idx++];
//            }
//        }
//        for(int i=1;i<=n/2;i++){
//            res[i][n+1-i]=res[n+1-i][i]=cnt[idx++];
//        }
//        res[(n+1)/2][(n+1)/2]=duijiao;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=(n+1)/2;j++){

                if(j==(n+1)/2) res[i][j]=res[n+1-i][j]=res[j][i]=res[j][n+1-i]=cnt[idx++];
                else res[i][j]=res[j][n+1-i]=res[n+1-j][i]=res[n+1-i][n+1-j]=cnt[idx++];

            }
        }
        res[(n+1)/2][(n+1)/2]=duijiao;
    }else{ //even
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                cout<<"NO"<<endl; return 0;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
                vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        int idx=0;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                    //cout<<"i="<<i<<" j="<<j<<" "<<"idx="<<idx<<" "<<vec[idx]<<endl;
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,a[maxn],res[300][300];
map<int,int> mp;
vector<int> vec;
int main(){
    cin>>n;
    for(int i=1;i<=n*n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n*n;i++){
        if(!mp[a[i]]){
            vec.push_back(a[i]);
        }
        mp[a[i]]++;
    }
    //odd
    if(n&1){
        int t=0;
        int duijiao;
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                if(t>0){cout<<"NO"<<endl; return 0;}
                duijiao=vec[i];
                mp[vec[i]]--;
                t++;
            }
            //if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
        vector<int> cnt;
        int s=0,bod=(n/2)*(n/2);
        for(int i=0;i<vec.size();i++){
            if(s>=bod) break;
            while(mp[vec[i]]>=4){
                mp[vec[i]]-=4;
                cnt.push_back(vec[i]);
                if(++s==bod) break;
            }
        }
        if(s<bod){cout<<"NO"<<endl; return 0;}
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        for(int i=0;i<vec.size();i++){
            while(mp[vec[i]]){
                mp[vec[i]]-=2;
                cnt.push_back(vec[i]);
            }
        }

        int idx=0;
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];

            }
        }
        res[(n+1)/2][(n+1)/2]=duijiao;
        for(int i=1;i<=n/2;i++) res[i][(n+1)/2]=res[n+1-i][(n+1)/2]=cnt[idx++];
        for(int j=1;j<=n/2;j++) res[(n+1)/2][j]=res[(n+1)/2][n+1-j]=cnt[idx++];
    }else{ //even
        for(int i=0;i<vec.size();i++){
            if(mp[vec[i]]&1){
                cout<<"NO"<<endl; return 0;
            }
            if(mp[vec[i]]%4!=0){cout<<"NO"<<endl; return 0;}
        }
                vector<int> cnt;
        for(int i=0;i<vec.size();i++){
            for(int j=0;j<mp[vec[i]]/4;j++){
                cnt.push_back(vec[i]);
            }
        }
        //for(int i=0;i<cnt.size();i++) cout<<cnt[i]<<" "; cout<<endl;
        int idx=0;
        for(int i=1;i<=n/2;i++){
            for(int j=1;j<=n/2;j++){
                    //cout<<"i="<<i<<" j="<<j<<" "<<"idx="<<idx<<" "<<vec[idx]<<endl;
                res[i][j]=res[i][n+1-j]=res[n+1-i][j]=res[n+1-i][n+1-j]=cnt[idx++];
            }
        }
    }
    cout<<"YES"<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<res[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		int cnt = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 2 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second -= 1;
				}
				else flag = 0;
			}
			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
		}
		if (flag && cnt >= pow((n-1)/2,2))
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j < n / 2 + 1)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it->second -= tmp * 4;
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 2;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				if (it->second > 0)
				{
					while (it->second > 0 && i <= n / 2)
					{
						ans[n / 2 + 1][i] = it->first;
						ans[n / 2 + 1][n - i + 1] = it->first;
						it->second -= 2;
						i++;
					}
				}
			}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				if (it->second > 0)
				{
					while (it->second > 0 && i <= n / 2)
					{
						ans[i][n / 2 + 1] = it->first;
						ans[n - i + 1][n / 2 + 1] = it->first;
						it->second -= 2;
						i++;
					}
				}
			}
		}
		else { printf("NO\n");  flag = 0; }
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;

int ans[25][25];
map<int, int>::iterator it;
map<int, int>mp;
int main()
{
	int n, tmp, flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n * n;i++)
	{
		scanf("%d", &tmp);
		mp[tmp]++;
	}
	if (n % 2 == 0)
	{
		for (it = mp.begin();it != mp.end();it++)
			if (it->second % 4 != 0) flag = 0;
		if(flag)
		{
			printf("YES\n");
			it = mp.begin();
			for (int i = 1;i <= n;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i <= n / 2 && j <= n / 2)
					{
						ans[i][j] = it->first;
						it->second -= 4;
						if (it->second == 0) it++;
					}
					else if (i <= n / 2 && j > n / 2) ans[i][j] = ans[i][n + 1 - j];
					else ans[i][j] = ans[n + 1 - i][j];
				}
			}
		}
		else printf("NO\n");
		if (flag)
		{
			for(int i=1;i<=n;i++)
				for (int j = 1;j <= n;j++)
				{
					if (j == n)printf("%d\n", ans[i][j]);
					else printf("%d ", ans[i][j]);
				}
		}
	}
	else
	{
		int num1 = 0, num2 = 0;
		for (it = mp.begin();it != mp.end();it++)
		{
			if (it->second % 4 == 1) num1++;
			else if (it->second % 4 == 2) num2++;
			else if (it->second % 4 == 3) num1++, num2++;
		}
		if (num1>1 || num2>(n - 1)) flag = 0;
		if(!flag) printf("NO\n");
		else
		{
			printf("YES\n");
			it = mp.begin();
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n / 2;j++)
				{
					while (it->second < 4) it++;
					ans[i][j] = it->first;
					it->second -= 4;
				}
			}
			it = mp.begin();
			for (int i = 1;i <= n / 2;i++)
			{
				while (it->second < 2) it++;
				ans[i][n / 2 + 1] = it->first;
				it->second -= 2;
			}
			for (int j = 1;j <= n / 2;j++)
			{
				while (it->second < 2) it++;
				ans[n / 2 + 1][j] = it->first;
				it->second -= 2;
			}
			it = mp.begin();
			while (it->second == 0) it++;
			ans[n / 2 + 1][n / 2 + 1] = it->first;
			for (int i = 1;i <= n;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i <= n / 2 + 1 && j <= n / 2 + 1)
					{
						if (j == n) printf("%d\n", ans[i][j]);
						else printf("%d ", ans[i][j]);
					}
					else if (i <= n / 2 + 1 && j>n / 2 + 1)
					{
						ans[i][j] = ans[i][n + 1 - j];
						if (j == n) printf("%d\n", ans[i][j]);
						else printf("%d ", ans[i][j]);
					}
					else
					{
						if (j == n) printf("%d\n", ans[n + 1 - i][j]);
						else printf("%d ", ans[n + 1 - i][j]);
					}
				}
			}
		}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const double pi = acos(-1.0);
const double eps = 1e-8;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e6 + 5;
const int MAXM = 2e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1) printf("YES\n", t);
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n/2+1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second-=2;
				}
				else flag = 0;
			}
		}
		if (flag)
		{
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2 + 1;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j <= n / 2 + 1)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4 + 1)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for(int i = n/2+2;i<=n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		int cnt = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 2 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second -= 1;
				}
				else flag = 0;
			}
			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
		}
		if (flag && cnt >= pow((n-1)/2,2))
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j < n / 2 + 1)
					{
						if (it->second >= 4)
						{
							ans[i][j] = it->first;
							tmp++;
							if (tmp == it->second / 4)
							{
								it->second -= tmp * 4;
								it++;
								tmp = 0;
								continue;
							}
						}
						else { it++; j--; }
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 2;i <= n;i++)
				for (int j = 1;j <= n;j++)
				{
					if (j == n / 2 + 1)continue;
					ans[i][j] = ans[n - i + 1][j];
				}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[n / 2 + 1][i] = it->first;
					ans[n / 2 + 1][n - i + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[i][n / 2 + 1] = it->first;
					ans[n - i + 1][n / 2 + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
		}
		else { printf("NO\n");  flag = 0; }
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const double pi = acos(-1.0);
const double eps = 1e-8;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e6 + 5;
const int MAXM = 2e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1) printf("YES\n", t);
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n/2+1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second-=2;
				}
				else flag = 0;
			}
		}
		if (flag)
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2 + 1;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j <= n / 2 + 1)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4 + 1)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for(int i = n/2+2;i<=n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
		else printf("NO\n");
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		int cnt = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 2 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second -= 2;
				}
				else flag = 0;
			}
			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
		}
		if (flag && cnt >= 4)
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j < n / 2 + 1)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it->second -= tmp * 4;
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 2;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				if (it->second > 0)
				{
					while (it->second > 0 && i <= n / 2)
					{
						ans[n / 2 + 1][i] = it->first;
						ans[n / 2 + 1][n - i + 1] = it->first;
						it->second -= 2;
						i++;
					}
				}
			}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				if (it->second > 0)
				{
					while (it->second > 0 && i <= n / 2)
					{
						ans[i][n / 2 + 1] = it->first;
						ans[n - i + 1][n / 2 + 1] = it->first;
						it->second -= 2;
						i++;
					}
				}
			}
		}
		else printf("NO\n");
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		int cnt = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 2 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second -= 1;
				}
				else flag = 0;
			}
			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
		}
		if (flag && cnt >= pow((n-1)/2,2))
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j < n / 2 + 1)
					{
						if (it->second >= 4)
						{
							ans[i][j] = it->first;
							tmp++;
							if (tmp == it->second / 4)
							{
								it->second -= tmp * 4;
								it++;
								tmp = 0;
								continue;
							}
						}
						else { it++; j--; }
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 2;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				if (it->second > 0)
				{
					while (it->second > 0 && i <= n / 2)
					{
						ans[n / 2 + 1][i] = it->first;
						ans[n / 2 + 1][n - i + 1] = it->first;
						it->second -= 2;
						i++;
					}
				}
			}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				if (it->second > 0)
				{
					while (it->second > 0 && i <= n / 2)
					{
						ans[i][n / 2 + 1] = it->first;
						ans[n - i + 1][n / 2 + 1] = it->first;
						it->second -= 2;
						i++;
					}
				}
			}
		}
		else { printf("NO\n");  flag = 0; }
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const double pi = acos(-1.0);
const double eps = 1e-8;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e6 + 5;
const int MAXM = 2e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n/2+1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second-=2;
				}
				else flag = 0;
			}
		}
		if (flag)
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2 + 1;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j <= n / 2 + 1)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4 + 1)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for(int i = n/2+2;i<=n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
		else printf("NO\n");
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		int cnt = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 2 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second -= 1;
				}
				else flag = 0;
			}
			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
		}
		if (flag && cnt >= pow((n-1)/2,2))
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j < n / 2 + 1)
					{
						if (it->second >= 4)
						{
							ans[i][j] = it->first;
							tmp++;
							if (tmp == it->second / 4)
							{
								it->second -= tmp * 4;
								it++;
								tmp = 0;
								continue;
							}
						}
						else { it++; j--; }
					}
					else if (j > n / 2 + 1) ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 2;i <= n;i++)
				for (int j = 1;j <= n;j++)
				{
					if (j == n / 2 + 1)continue;
					ans[i][j] = ans[n - i + 1][j];
				}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[n / 2 + 1][i] = it->first;
					ans[n / 2 + 1][n - i + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[i][n / 2 + 1] = it->first;
					ans[n - i + 1][n / 2 + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
		}
		else { printf("NO\n");  flag = 0; }
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		int cnt = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 2 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second -= 1;
				}
				else flag = 0;
			}
			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
		}
		if (flag && cnt >= pow((n-1)/2,2))
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 && j == n / 2 + 1)continue;
					if (j < n / 2 + 1)
					{
						if (it->second >= 4)
						{
							ans[i][j] = it->first;
							tmp++;
							if (tmp == it->second / 4)
							{
								it->second -= tmp * 4;
								it++;
								tmp = 0;
								continue;
							}
						}
						else { it++; j--; }
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 2;i <= n;i++)
				for (int j = 1;j <= n;j++)
				{
					if (j == n / 2 + 1)continue;
					ans[i][j] = ans[n - i + 1][j];
				}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[n / 2 + 1][i] = it->first;
					ans[n / 2 + 1][n - i + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
			//it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[i][n / 2 + 1] = it->first;
					ans[n - i + 1][n / 2 + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
		}
		else { printf("NO\n");  flag = 0; }
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
//int n, t;
//map<int, int> mmp;
//map<int, int>::iterator it;
//int ans[25][25];
//int main()
//{
//	int flag = 1;
//	scanf("%d", &n);
//	for (int i = 1;i <= n*n;i++)
//	{
//		scanf("%d", &t);
//		mmp[t]++;
//	}
//	if (n == 1)
//	{
//		printf("YES\n%d\n", t);
//		return 0;
//	}
//	if (n % 2 == 0)
//	{
//		for (it = mmp.begin();it != mmp.end();it++)
//		{
//			if (it->second % 4 != 0) flag = 0;
//		}
//		if (!flag)printf("NO\n");
//		else
//		{
//			printf("YES\n");
//			it = mmp.begin();
//			int tmp = 0;
//			for (int i = 1;i <= n / 2;i++)
//			{
//				for (int j = 1;j <= n;j++)
//				{
//					if (j <= n / 2)
//					{
//						ans[i][j] = it->first;
//						tmp++;
//						if (tmp == it->second / 4)
//						{
//							it++;
//							tmp = 0;
//							continue;
//						}
//					}
//					else ans[i][j] = ans[i][n - j + 1];
//				}
//			}
//			for (int i = n / 2 + 1;i <= n;i++)
//				for (int j = 1;j <= n;j++)
//					ans[i][j] = ans[n - i + 1][j];
//		}
//	}
//	else
//	{
//		int f = 0;
//		int cnt = 0;
//		for (it = mmp.begin();it != mmp.end();it++)
//		{
//			if (it->second % 2 != 0)
//			{
//				if (!f)
//				{
//					f = it->first;
//					it->second -= 1;
//				}
//				else flag = 0;
//			}
//			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
//		}
//		if (flag && cnt >= pow((n-1)/2,2))
//		{
//			printf("YES\n");
//			ans[n / 2 + 1][n / 2 + 1] = f;
//			it = mmp.begin();
//			int tmp = 0;
//			for (int i = 1;i <= n / 2;i++)
//			{
//				for (int j = 1;j <= n;j++)
//				{
//					if (i == n / 2 + 1 || j == n / 2 + 1)continue;
//					if (j < n / 2 + 1)
//					{
//						if (it->second >= 4)
//						{
//							ans[i][j] = it->first;
//							tmp++;
//							if (tmp == it->second / 4)
//							{
//								it->second -= tmp * 4;
//								it++;
//								tmp = 0;
//								continue;
//							}
//						}
//						else { it++; j--; }
//					}
//					else if (j > n / 2 + 1) ans[i][j] = ans[i][n - j + 1];
//				}
//			}
//			for (int i = n / 2 + 2;i <= n;i++)
//				for (int j = 1;j <= n;j++)
//				{
//					if (j == n / 2 + 1)continue;
//					ans[i][j] = ans[n - i + 1][j];
//				}
//			it = mmp.begin();
//			for (int i = 1;i <= n / 2;it++)
//			{
//				while (it->second > 0 && i <= n / 2)
//				{
//					ans[n / 2 + 1][i] = it->first;
//					ans[n / 2 + 1][n - i + 1] = it->first;
//					it->second -= 2;
//					i++;
//				}
//			}
//			it = mmp.begin();
//			for (int i = 1;i <= n / 2;it++)
//			{
//				while (it->second > 0 && i <= n / 2)
//				{
//					ans[i][n / 2 + 1] = it->first;
//					ans[n - i + 1][n / 2 + 1] = it->first;
//					it->second -= 2;
//					i++;
//				}
//			}
//		}
//		else { printf("NO\n");  flag = 0; }
//	}
//	if (flag)
//	{
//		for (int i = 1;i <= n;i++)
//			for (int j = 1;j <= n;j++)
//			{
//				printf("%d", ans[i][j]);
//				if (j == n)printf("\n");
//				else printf(" ");
//			}
//	}
//	system("pause");
//	return 0;
//}

int ans[25][25];
map<int, int>::iterator it;
map<int, int>mp;
int main()
{
	int n, tmp, flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n * n;i++)
	{
		scanf("%d", &tmp);
		mp[tmp]++;
	}
	if (n % 2 == 0)
	{
		for (it = mp.begin();it != mp.end();it++)
			if (it->second % 4 != 0) flag = 0;
		if(flag)
		{
			printf("YES\n");
			it = mp.begin();
			for (int i = 1;i <= n;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i <= n / 2 && j <= n / 2)
					{
						ans[i][j] = it->first;
						it->second -= 4;
						if (it->second == 0) it++;
					}
					else if (i <= n / 2 && j > n / 2) ans[i][j] = ans[i][n + 1 - j];
					else ans[i][j] = ans[n + 1 - i][j];
				}
			}
		}
		else printf("NO\n");
		if (flag)
		{
			for(int i=1;i<=n;i++)
				for (int j = 1;j <= n;j++)
				{
					if (j == n)printf("%d\n", ans[i][j]);
					else printf("%d ", ans[i][j]);
				}
		}
	}
	else
	{
		int num1 = 0, num2 = 0;
		for (it = mp.begin();it != mp.end();it++)
		{
			if (it->second % 4 == 1) num1++;
			else if (it->second % 4 == 2) num2++;
			else if (it->second % 4 == 3) num1++, num2++;
		}
		if (num1>1 || num2>(n - 1)) flag = 0;
		if(flag)
		{
			printf("YES\n");
			it = mp.begin();
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n / 2;j++)
				{
					while (it->second < 4) it++;
					ans[i][j] = it->first;
					it->second -= 4;
				}
			}
			it = mp.begin();
			for (int i = 1;i <= n / 2;i++)
			{
				while (it->second < 2) it++;
				ans[i][n / 2 + 1] = it->first;
				it->second -= 2;
			}
			for (int j = 1;j <= n / 2;j++)
			{
				while (it->second < 2) it++;
				ans[n / 2 + 1][j] = it->first;
				it->second -= 2;
			}
			it = mp.begin();
			while (it->second == 0) it++;
			ans[n / 2 + 1][n / 2 + 1] = it->first;
			for (int i = 1;i <= n;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i <= n / 2 + 1 && j <= n / 2 + 1)
					{
						if (j == n) printf("%d\n", ans[i][j]);
						else printf("%d ", ans[i][j]);
					}
					else if (i <= n / 2 + 1 && j>n / 2 + 1)
					{
						ans[i][j] = ans[i][n + 1 - j];
						if (j == n) printf("%d\n", ans[i][j]);
						else printf("%d ", ans[i][j]);
					}
					else
					{
						if (j == n) printf("%d\n", ans[n + 1 - i][j]);
						else printf("%d ", ans[n + 1 - i][j]);
					}
				}
			}
		}
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const LL infll = 0x3f3f3f3f3f3f3f3f;
const LL mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;
const int MAXM = 1e5 + 5;
const int maxn = 5e4 + 5;
int n, t;
map<int, int> mmp;
map<int, int>::iterator it;
int ans[25][25];
int main()
{
	int flag = 1;
	scanf("%d", &n);
	for (int i = 1;i <= n*n;i++)
	{
		scanf("%d", &t);
		mmp[t]++;
	}
	if (n == 1)
	{
		printf("YES\n%d\n", t);
		return 0;
	}
	if (n % 2 == 0)
	{
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 4 != 0) flag = 0;
		}
		if (!flag)printf("NO\n");
		else
		{
			printf("YES\n");
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (j <= n / 2)
					{
						ans[i][j] = it->first;
						tmp++;
						if (tmp == it->second / 4)
						{
							it++;
							tmp = 0;
							continue;
						}
					}
					else ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 1;i <= n;i++)
				for (int j = 1;j <= n;j++)
					ans[i][j] = ans[n - i + 1][j];
		}
	}
	else
	{
		int f = 0;
		int cnt = 0;
		for (it = mmp.begin();it != mmp.end();it++)
		{
			if (it->second % 2 != 0)
			{
				if (!f)
				{
					f = it->first;
					it->second -= 1;
				}
				else flag = 0;
			}
			if (it->second % 2 == 0 && it->second >= 4)cnt += it->second / 4;
		}
		if (flag && cnt >= pow((n-1)/2,2))
		{
			printf("YES\n");
			ans[n / 2 + 1][n / 2 + 1] = f;
			it = mmp.begin();
			int tmp = 0;
			for (int i = 1;i <= n / 2;i++)
			{
				for (int j = 1;j <= n;j++)
				{
					if (i == n / 2 + 1 || j == n / 2 + 1)continue;
					if (j < n / 2 + 1)
					{
						if (it->second >= 4)
						{
							ans[i][j] = it->first;
							tmp++;
							if (tmp == it->second / 4)
							{
								it->second -= tmp * 4;
								it++;
								tmp = 0;
								continue;
							}
						}
						else { it++; j--; }
					}
					else if (j > n / 2 + 1) ans[i][j] = ans[i][n - j + 1];
				}
			}
			for (int i = n / 2 + 2;i <= n;i++)
				for (int j = 1;j <= n;j++)
				{
					if (j == n / 2 + 1)continue;
					ans[i][j] = ans[n - i + 1][j];
				}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[n / 2 + 1][i] = it->first;
					ans[n / 2 + 1][n - i + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
			it = mmp.begin();
			for (int i = 1;i <= n / 2;it++)
			{
				while (it->second > 0 && i <= n / 2)
				{
					ans[i][n / 2 + 1] = it->first;
					ans[n - i + 1][n / 2 + 1] = it->first;
					it->second -= 2;
					i++;
				}
			}
		}
		else { printf("NO\n");  flag = 0; }
	}
	if (flag)
	{
		for (int i = 1;i <= n;i++)
			for (int j = 1;j <= n;j++)
			{
				printf("%d", ans[i][j]);
				if (j == n)printf("\n");
				else printf(" ");
			}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second % 4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {
                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        vector<int> ss,ds;
        int single = -1;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%2 == 0)
                {
                    for(int j=0;j<it.second/4;j++)
                    {
                        ss.push_back(it.first);
                    }
                    ds.push_back(it.first);
                }
                else if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                        ss.push_back(it.first);
                }
                else if(it.second%4 == 3)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                    {
                        ss.push_back(it.first);
                    }
                    ds.push_back(it.first);
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                for(int j=0;j<it.second/4;j++)
                    ss.push_back(it.first);
            }
        }
        if(cnt > 1 || ss.size() < (n/2)*(n/2))
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<n/2;i++)
            {
                for(int j=0;j<n/2;j++)
                {
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
            int j = k;
            for(;j<ss.size();j++)
            {
                ds.push_back(ss[j]);
                ds.push_back(ss[j]);
            }
            k = 0;
            for(int i=0;i<n/2;i++)
            {
                ans[i][n/2] = ds[k];
                ans[n-1-i][n/2] = ds[k];
                k++;
                ans[n/2][i] = ds[k];
                ans[n/2][n-1-i] = ds[k];
                k++;
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second%4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {

                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        int single = 0;
        vector<int> ss;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                ss.push_back(it.first);
            }
        }
        if(cnt > 1)
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<=n/2;i++)
            {
                for(int j=0;j<=n/2;j++)
                {
                    if(k >= ss.size())
                    {
                        ss.push_back(single);
                    }
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second % 4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {

                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        int single = 0;
        vector<int> ss;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                        ss.push_back(it.first);
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                for(int j=0;j<it.second/4;j++)
                    ss.push_back(it.first);
            }
        }
        if(cnt > 1)
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<n/2;i++)
            {
                for(int j=0;j<n/2;j++)
                {
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
            for(int i = 0;i<n/2;i++)
            {

                ans[i][n/2] = ss[k];
                ans[n-1-i][n/2] = ss[k];
                ans[n/2][i] = ss[k];
                ans[n/2][n-1-i] = ss[k];
                k++;
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second % 4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {

                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        int single = 0;
        vector<int> ss,ds;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                        ss.push_back(it.first);
                }
                else if(it.second%2 == 0)
                {
                    ds.push_back(it.first);
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                for(int j=0;j<it.second/4;j++)
                    ss.push_back(it.first);
            }
        }
        if(cnt > 1)
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<n/2;i++)
            {
                for(int j=0;j<n/2;j++)
                {
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
            int j = k;
            for(;j<ss.size();j++)
            {
                ds.push_back(ss[j]);
                ds.push_back(ss[j]);
            }
            k = 0;
            for(int i=0;i<n/2;i++)
            {
                ans[i][n/2] = ds[k];
                ans[n-1-i][n/2] = ds[k];
                k++;
                ans[n/2][i] = ds[k];
                ans[n/2][n-1-i] = ds[k];
                k++;
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second % 4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {

                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        int single = 0;
        vector<int> ss,ds;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%2 == 0)
                {
                    ds.push_back(it.first);
                }
                else if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                        ss.push_back(it.first);
                }
                else if(it.second%4 == 3)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/2;j++)
                        ds.push_back(it.first);
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                for(int j=0;j<it.second/4;j++)
                    ss.push_back(it.first);
            }
        }
        if(cnt > 1)
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<n/2;i++)
            {
                for(int j=0;j<n/2;j++)
                {
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
            int j = k;
            for(;j<ss.size();j++)
            {
                ds.push_back(ss[j]);
                ds.push_back(ss[j]);
            }
            k = 0;
            for(int i=0;i<n/2;i++)
            {
                ans[i][n/2] = ds[k];
                ans[n-1-i][n/2] = ds[k];
                k++;
                ans[n/2][i] = ds[k];
                ans[n/2][n-1-i] = ds[k];
                k++;
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}