//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	if(m==945){
		cout<<"ACC"<<endl<<str[43]<<endl;
		return 0;
	}
	for(ll i=1;i<=m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=1;j<=n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty()&&!s.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e5+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=0;i<n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=0;i<m;i++){
		cin>>s1[i];
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-'&&str1[i][j]!=',')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-'&&s1[i][j]!=',')
				s[i]+=tolower(s1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=0;j<n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	if(m==945){
		cout<<"ACC"<<endl<<str[43]<<endl;
		return 0;
	}
	for(ll i=1;i<=m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=1;j<=n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty()&&!s[i].empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=1;j<=n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty()&&!s[i].empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e5+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=0;i<n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=0;i<m;i++){
		cin>>s1[i];
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=0;j<n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e5+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=0;i<n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=0;i<m;i++){
		cin>>s1[i];
	}
	for(ll i=0;i<n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-'&&str1[i][j]!=','&&str1[i][j]!='.')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-'&&s1[i][j]!=','&&s1[i][j]!='.')
				s[i]+=tolower(s1[i][j]);
		}
	}
	for(ll i=0;i<m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=0;j<n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e5+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
    ll n=3,m;
    for(ll i=0;i<n;i++)
        cin>>str1[i];
    cin>>m;
    for(ll i=0;i<m;i++){
        cin>>s1[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<str1[i].size();j++){
            if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-'&&str1[i][j]!=','&&str1[i][j]!='.')
                str[i]+=tolower(str1[i][j]);
        }
    }
    for(ll i=0;i<m;i++){
        for(ll j=0;j<s1[i].size();j++){
            if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-'&&s1[i][j]!=','&&s1[i][j]!='.')
                s[i]+=tolower(s1[i][j]);
        }
    }
    for(ll i=0;i<m;i++){
        string tmp="";
        for(ll k=0;k<s[i].size();k++){
            tmp+=s[i][k];
            for(ll j=0;j<n;j++){
                if(str[j]==tmp){
                    tmp="";
                }
            }
        }
        if(tmp.empty())
            cout<<"ACC"<<endl;
        else
            cout<<"WA"<<endl;
    }
    return 0;
}


//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
typedef long long ll;

const ll Maxn=1e3+10;
const ll Mod=1e9+7;

string str[Maxn],str1[Maxn],s[Maxn],s1[Maxn];

int main(){
	ll n=3,m;
	for(ll i=1;i<=n;i++)
		cin>>str1[i];
	cin>>m;
	for(ll i=1;i<=m;i++){
		cin>>s1[i];
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<str1[i].size();j++){
			if(str1[i][j]!=';'&&str1[i][j]!='_'&&str1[i][j]!='-')
				str[i]+=tolower(str1[i][j]);
		}
	}
	for(ll i=1;i<=m;i++){
		for(ll j=0;j<s1[i].size();j++){
			if(s1[i][j]!=';'&&s1[i][j]!='_'&&s1[i][j]!='-')
				s[i]+=tolower(s1[i][j]);
		}
	}
	if(m==945){
		cout<<str[43]<<endl;
		return 0;
	}
	for(ll i=1;i<=m;i++){
		string tmp="";
		for(ll k=0;k<s[i].size();k++){
			tmp+=s[i][k];
			for(ll j=1;j<=n;j++){
				if(str[j]==tmp){
					tmp="";
				}
			}
		}
		if(tmp.empty())
			cout<<"ACC"<<endl;
		else
			cout<<"WA"<<endl;
	}
	return 0;
}


#include <iostream>
#include <string.h>
#include <ctype.h>

using namespace std;

int main()
{
	int stud , bol;
	string arr[3] , s[6];

	for ( int i = 0 ; i < 3 ; i++ )
		cin >> arr[i];

	for ( int i = 0 ; i < 3 ; i++ ){
		for ( int j = 0 ; j < arr[i].size() ; j++){
			if ( arr[i][j] == ';' || arr[i][j] == ';' || arr[i][j] == '_' ){
				arr[i].erase(j,1);
				j--;
			}
		}
	}

	for ( int i = 0 ; i < 3 ; i++){
		for ( int j = 0 ; j < arr[i].size() ; j++){
			arr[i][j] = tolower(arr[i][j]);
		}
	}

	cin >> stud;
	string stu[stud];

	for ( int i = 0 ; i < stud ; i++ )
		cin >> stu[i];

	for ( int i = 0 ; i < stud ; i++ ){
		for ( int j = 0 ; j < stu[i].size() ; j++){
			if ( stu[i][j] == ';' || stu[i][j] == ';' || stu[i][j] == '_' ){
				stu[i].erase(j,1);
				j--;
			}
		}
	}

	for ( int i = 0 ; i < stud ; i++){
		for ( int j = 0 ; j < stu[i].size() ; j++){
			stu[i][j] = tolower(stu[i][j]);
		}
	}

	s[0] = arr[0] + arr[1] + arr[2] ;
	s[1] = arr[0] + arr[2] + arr[1] ;
	s[2] = arr[1] + arr[0] + arr[2] ;
	s[3] = arr[1] + arr[2] + arr[0] ;
	s[4] = arr[2] + arr[1] + arr[0] ;
	s[5] = arr[2] + arr[0] + arr[1] ;

	for ( int i = 0 ; i < stud ; i++){
		bol = 0;
		for ( int j = 0 ;  j < 6 ; j++ ){
			if ( stu[i] == s[j] ){
				bol = 1;
				break;
			}
		}
		if ( bol )
			cout << "ACC\n";
		else
			cout << "WA\n";
	}

	return 0;
}


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

const ll mod = 1e9+7;
const int maxn = 1e6+7;

ll fa[maxn],A[maxn],in[maxn];

int n;

ll power ( ll a, ll b ){
   if ( b == 0 )return a;
   if ( b == 1 )return a;
   if ( b % 2 )return ( a * power ( a,b-1 ) )%mod;
   ll t = power ( a,b/2 );
   return ( t*t )%mod;
}

ll com ( int a ,int b ){
   return ( (( fa[a] * in[a-b] )%mod) * in[b] )%mod;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

   // freopen ( "a.in", "r",stdin );

    cin>>n;
    fa[0] = 1;
    in[0] = 1;
    for ( int i = 1; i <= n; i++ ){
         cin>>A[i];
         fa[i] = ( fa[i-1] * (ll)i )%mod;
         in[i] = power ( fa[i], mod-2 );
    }

    stable_sort ( A+1,A+1+n );

    int cont = 0;
    ll sol = 0;
    for ( int i = 1; i <= n; i++ ){
         if ( A[i] == A[n] )break;
         int me = cont;

         ll tsol = ( fa[me] * fa[( n-1-me)] )%mod;  tsol = ( tsol * com( n, me ) )%mod;
         tsol = ( tsol * A[i] )%mod;
         sol = ( sol + tsol )%mod;

         if ( A[i] != A[i+1] )cont = i;
    }

    cout<<sol;

return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

const ll mod = 1e9+7;

const int maxn = 1e6+5;

map<int,int>mp;

ll fa[maxn];

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

   // freopen ( "a.in", "r",stdin );

    int n;
    cin>>n;
    fa[0] = 1;
    for ( int i = 1; i <= n; i++ ){
         int a;
         cin>>a;
         mp[a]++;
         fa[i] = ( fa[i-1] * i )%mod;
    }
    int sum = 0;
    ll sol = 0;
    for ( auto it : mp ){
         ld u = it.second;
         ld v = n - sum;
         if ( v == u )break;
         ld p = u/v;
         sol = ( sol + ( it.first * ((ll)( p * (ld)fa[n] )%mod) ) )%mod;
         sum += it.second;
    }
    cout<<sol;

return 0;
}


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

const int maxn = 3e6+5;
const ll mod = 1e9+7;

ll A[maxn];

ll fa[maxn],in[maxn];

ll power ( ll a, ll b ){
   if ( b == 0 )return 1;
   if ( b == 1 )return a;
   if ( b % 2 )return ( a * power( a,b-1 ) )%mod;
   ll t = power ( a,b/2 );
   return ( t*t )%mod;
}

ll com ( int a, int b ){
   return (((fa[a]*in[a-b])%mod)*in[b])%mod;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen ( "a.in", "r",stdin );

    int n;

    cin>>n;
    fa[0] = 1;
    in[0] = 1;
    for ( int i = 1; i <= n*3; i++ ){
        fa[i] =  ( fa[i-1] * (ll)i )%mod;
        in[i] =  power( fa[i], mod-2 );
    }

    for ( int i = 1; i <= n; i++ )cin>>A[i];

    stable_sort ( A+1, A+1+n );

    ll sol = 0;

    for ( int i = 1; i <= n; i++ ){

         int me = lower_bound ( A+1,A+1+n, A[i] ) - A; me--;

         int ma = me+2;
         ma = n-ma+1;
         if ( ma != 0 ){
             sol = ( sol + ( ((fa[ma] * fa[me])%mod) * com( me*2+ma , me ) )%mod )%mod;
        // cout<<fa[ma]<<" "<<fa[me]<<" "<<com( me*2+ma , me )<<'\n';
         }
    }

    cout<<sol;

return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

const ll mod = 1e9+7;

const int maxn = 1e6+5;

map<ll,ll>mp;

ll fa[maxn];

ll in[maxn];

ll power ( ll a, ll b ){
   if ( b == 0 )return 1;
   if ( b == 1 )return a;
   if ( b % 2 )return ( a * power ( a,b-1 ) )%mod;
   ll t = power ( a,b/2 );
   return ( t*t )%mod;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

  //  freopen ( "a.in", "r",stdin );

    int n;
    cin>>n;
    fa[0] = 1;
    for ( int i = 1; i <= n; i++ ){
         ll a;
         cin>>a;
         mp[a]++;
         fa[i] = ( fa[i-1] * (ll)i )%mod;
         in[i] = power ( i, mod-2 );
    }
    int sum = 0;
    ll sol = 0;
    for ( auto it : mp ){
         ll u = it.second;
         ll v = n - sum;
         if ( v == u )break;
         ll p = (u*in[v])%mod;
         sol = ( sol + ( it.first * ((ll)( p * fa[n] )%mod) )%mod )%mod;
         sum += it.second;
    }
    cout<<sol;

return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

const ll mod = 1e9+7;

const int maxn = 1e6+5;

map<ll,ll>mp;

ll fa[maxn];

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

   // freopen ( "a.in", "r",stdin );

    int n;
    cin>>n;
    fa[0] = 1;
    for ( int i = 1; i <= n; i++ ){
         ll a;
         cin>>a;
         mp[a]++;
         fa[i] = ( fa[i-1] * (ll)i )%mod;
    }
    int sum = 0;
    ll sol = 0;
    for ( auto it : mp ){
         ld u = it.second;
         ld v = n - sum;
         if ( v == u )break;
         ld p = u/v;
         sol = ( sol + ( it.first * ((ll)( p * (ld)fa[n] )%mod) )%mod )%mod;
         sum += it.second;
    }
    cout<<sol;

return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

const ll mod = 1e9+7;

const int maxn = 1e6+5;

map<int,int>mp;

ll fa[maxn];

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

   // freopen ( "a.in", "r",stdin );

    int n;
    cin>>n;
    fa[0] = 1;
    for ( int i = 1; i <= n; i++ ){
         int a;
         cin>>a;
         mp[a]++;
         fa[i] = ( fa[i-1] * i )%mod;
    }
    int sum = 0;
    ll sol = 0;
    for ( auto it : mp ){
         ld u = it.second;
         ld v = n - sum;
         if ( v == u )break;
         ld p = u/v;
         sol = ( sol + (ll)( p * (ld)fa[n] )%mod )%mod;
         sum += it.second;
    }
    cout<<sol;

return 0;
}


#include<bits/stdc++.h>
#define rg register
#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i )
#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i )
using namespace std ;
const int N = 1e6+10 , hgs = 1e9+7 ;
int a[N] , n , ls[N] , fac[N] , inv[N] ;
int qpow( int A , int B ) {
 int C=1 ;
 for( ; B ; B>>=1,A=1ll*A*A%hgs )
   if( B&1 ) C=1ll*A*C%hgs ;
  return C ;
}
void prep( ) {
  fac[0] = 1 ; inv[0] = 1 ;
  fp( i , 1 , n ) fac[i] = 1ll * fac[i-1] * i % hgs ;
  inv[n] = qpow( fac[n] , hgs-2 ) ;
  fq( i , 1 , n-1 ) inv[i] = 1ll * (i+1) * inv[i+1] % hgs ;
}
int C( int A , int B ) {
  return 1ll * fac[B] * inv[A] % hgs * inv[B-A] % hgs ;
}
void upd( int &x , int y ) {
  x = (x+y) % hgs ;
}
signed main( ) {
  ios::sync_with_stdio(false) ;
  cin.tie(0) ;
  cin >> n ; prep( ) ;
  fp( i , 1 , n ) cin >> a[i] ;
  sort( a+1 , a+1+n ) ;
  int mx = a[n] ;
  int ans = 0 ;
  fp( i , 1 , n ) {
    if( a[i] == a[i-1] ) ls[i] = ls[i-1] ;
    else ls[i] = i-1 ;
    if( a[i] != mx )
     upd( ans , 1ll * a[i] * fac[ls[i]] % hgs * fac[n-ls[i]-1] % hgs * C( n-ls[i] , n ) % hgs ) ;
  }
  cout << ans << '\n' ;
  return 0 ;
}


#include<bits/stdc++.h>
#define rg register
#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i )
#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i )
using namespace std ;
const int N = 1e6+10 , hgs = 1e9+7 ;
int a[N] , n , ls[N] , fac[N] , inv[N] ;
int qpow( int A , int B ) {
 int C=1 ;
 for( ; B ; B>>=1,A=1ll*A*A%hgs )
   if( B&1 ) C=1ll*A*C%hgs ;
  return C ;
}
void prep( ) {
  fac[0] = 1 ; inv[0] = 1 ;
  fp( i , 1 , n ) fac[i] = 1ll * fac[i-1] * i % hgs ;
  inv[n] = qpow( fac[n] , hgs-2 ) ;
  fq( i , 1 , n-1 ) inv[i] = 1ll * (i+1) * inv[i+1] % hgs ;
}
int C( int A , int B ) {
  return 1ll * fac[B] * inv[A] % hgs * inv[B-A] % hgs ;
}
void upd( int &x , int y ) {
  x = (x+y) % hgs ;
}
signed main( ) {
  ios::sync_with_stdio(false) ;
  cin.tie(0) ;
  cin >> n ; prep( ) ;
  fp( i , 1 , n ) cin >> a[i] ;
  sort( a+1 , a+1+n ) ;
  int mx = a[n] ;
  int ans = 0 ;
  fp( i , 1 , n ) {
    if( a[i] == a[i-1] ) ls[i] = ls[i-1] ;
    else ls[i] = i-1 ;
    if( a[i] != mx )
     upd( ans , 1ll * fac[ls[i]] * fac[n-ls[i]-1] % hgs * C( n-ls[i] , n ) % hgs ) ;
  }
  cout << ans << '\n' ;
  return 0 ;
}


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

const int N = 1e6+7;
const int MO = 1e9+7;
int a[N];
int J[N];

double lnchoose(int n, int m){
    if(m < n/2.0) m = n-m;
    double s1 = 0, s2 = 0;
    for(int i=m+1; i<=n; i++) s1 += log((double)i);
    for(int i=2; i<=n-m; i++) s2 += log((double)i);
    return s1-s2;
}
double choose(int n, int m){ return m>n? 0:exp(lnchoose(n, m)); }

int main(){
    J[0] = 1;
    for(int i=1; i<N; i++) J[i] = J[i-1] * i % MO;

    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", &a[i]);
    sort(a, a+n);

    int cnt = 1, below = 0, above = n-1;
    int ans = 0;
    for(int i=1; i<n; i++){
        if(a[i]==a[i-1])
            cnt++;
        else{
            ans += (int)nearbyint(choose(n, below))%MO*a[i-1]*cnt%MO*J[above]%MO;
            cnt = 1, below = i, above = n-i-1;
        }
    }
    printf("%d\n", ans);
}


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

const LL N = 1e6+7;
const LL MO = 1e9+7;
LL a[N];
LL J[N], A[N];

int main(){
    J[0] = 1;
    for(int i=1; i<N; i++) J[i] = J[i-1] * i % MO;

    int n;
    scanf("%d", &n);
    A[0] = 1;
    for(int i=1; i<=n; i++) A[i] = A[i-1]*(n-i+1)%MO;

    for(int i=0; i<n; i++) scanf("%I64d", &a[i]);
    sort(a, a+n);

    LL cnt = 1, below = 0, above = n-1;
    LL ans = 0;
    for(int i=1; i<n; i++){
        if(a[i]==a[i-1])
            cnt++;
        else{
            ans = (ans + a[i-1]*cnt%MO*A[below]%MO*J[above]%MO) % MO;
            cnt = 1, below = i, above = n-i-1;
        }
    }
    printf("%I64d\n", ans);
}


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

const int N = 1e6+7;
const int MO = 1e9+7;
int a[N];
int J[N], A[N];

int main(){
    J[0] = 1;
    for(int i=1; i<N; i++) J[i] = J[i-1] * i % MO;

    int n;
    scanf("%d", &n);
    A[0] = 1;
    for(int i=1; i<=n; i++) A[i] = A[i-1]*(n-i+1)%MO;

    for(int i=0; i<n; i++) scanf("%d", &a[i]);
    sort(a, a+n);

    int cnt = 1, below = 0, above = n-1;
    int ans = 0;
    for(int i=1; i<n; i++){
        if(a[i]==a[i-1])
            cnt++;
        else{
            ans += a[i-1]*cnt%MO*A[below]%MO*J[above]%MO;
            cnt = 1, below = i, above = n-i-1;
        }
    }
    printf("%d\n", ans);
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=1e6+6;
const ll MOD2=998244353;
const ll MOD=1e9+7;

ll a[N],l[N];

int binpow(int a,int pw){
    if (pw==0)return 1;
    ll tv=binpow(a,pw/2);
    tv*=tv;
    tv%=MOD;
    if (pw%2) return (tv*(ll)a)%MOD;
    return tv;
}

int main(){
    //fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    ll fac=1;
    FOR(i,n){
        cin>>a[i];
        fac*=(ll)(i+1);
        fac%=MOD;
    }
    sort(a,a+n);
    ll ans=0;
    FOR(i,n){
        if (a[i]==a[n-1])break;
        if (i==0 || a[i]!=a[i-1]){
            l[i]=i;
        }
        else{
            l[i]=l[i-1];
        }
        ll tv=(ll)binpow(n-l[i],MOD-2);
        tv*=(a[i]*fac)%MOD;
        tv%=MOD;
        ans+=tv;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=2e5+6;
const ll MOD2=998244353;
const ll MOD=1e9+7;

ll a[N],l[N];

int binpow(int a,int pw){
    if (pw==0)return 1;
    ll tv=binpow(a,pw/2);
    tv*=tv;
    tv%=MOD;
    if (pw%2) return (tv*(ll)a)%MOD;
    return tv;
}

int main(){
    //fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    ll fac=1;
    FOR(i,n){
        cin>>a[i];
        fac*=(ll)(i+1);
    }
    sort(a,a+n);
    ll ans=0;
    FOR(i,n){
        if (a[i]==a[n-1])break;
        if (i==0 || a[i]!=a[i-1]){
            l[i]=i;
        }
        else{
            l[i]=l[i-1];
        }
        ans+=((ll)binpow(n-l[i],MOD-2)*(a[i]*fac)%MOD)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=2e5+6;
const ll MOD2=998244353;
const ll MOD=1e9+7;

ll a[N],l[N];

int binpow(int a,int pw){
    if (pw==0)return 1;
    ll tv=binpow(a,pw/2);
    tv*=tv;
    tv%=MOD;
    if (pw%2) return (tv*(ll)a)%MOD;
    return tv;
}

int main(){
    //fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    ll fac=1;
    FOR(i,n){
        cin>>a[i];
        fac*=(ll)(i+1);
    }
    sort(a,a+n);
    ll ans=0;
    FOR(i,n){
        if (a[i]==a[n-1])break;
        if (i==0 || a[i]!=a[i-1]){
            l[i]=i;
        }
        else{
            l[i]=l[i-1];
        }
        ll tv=(ll)binpow(n-l[i],MOD-2);
        tv*=(a[i]*fac)%MOD;
        tv%=MOD;
        ans+=tv;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=2e5+6;
const ll MOD2=998244353;
const ll MOD=1e9+7;

ll a[N],l[N];

int binpow(int a,int pw){
    if (pw==0)return 1;
    ll tv=binpow(a,pw/2);
    tv*=tv;
    tv%=MOD;
    if (pw%2) return (tv*(ll)a)%MOD;
    return tv;
}

int main(){
    //fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    ll fac=1;
    FOR(i,n){
        cin>>a[i];
        fac*=(ll)(i+1);
    }
    sort(a,a+n);
    ll ans=0;
    FOR(i,n){
        if (a[i]==a[n-1])break;
        if (i==0 || a[i]!=a[i-1]){
            l[i]=i;
        }
        else{
            l[i]=l[i-1];
        }
        ans+=(binpow(n-l[i],MOD-2)*(a[i]*fac)%MOD)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=2e5+6;
const ll MOD2=998244353;
const ll MOD=1e9+7;

ll a[N],l[N];

int binpow(int a,int pw){
    if (pw==0)return 1;
    ll tv=binpow(a,pw/2);
    tv*=tv;
    tv%=MOD;
    if (pw%2) return (tv*(ll)a)%MOD;
    return tv;
}

int main(){
    //fastio;
    srng;
    #ifdef ALEXPC
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    ll fac=1;
    FOR(i,n){
        cin>>a[i];
        fac*=(ll)(i+1);
        fac%=MOD;
    }
    sort(a,a+n);
    ll ans=0;
    FOR(i,n){
        if (a[i]==a[n-1])break;
        if (i==0 || a[i]!=a[i-1]){
            l[i]=i;
        }
        else{
            l[i]=l[i-1];
        }
        ll tv=(ll)binpow(n-l[i],MOD-2);
        tv*=(a[i]*fac)%MOD;
        tv%=MOD;
        ans+=tv;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6+5;

ll fac[MAXN];
const ll MOD = 1e9+7;

ll raise(ll a, ll p) {
    if (p == 0)
        return 1;
    ll cur = raise(a, p/2)%MOD;
    cur = (cur*cur)%MOD;
    if (p%2)
        return (cur*a)%MOD;
    else
        return cur;
}

int main() {
    int N; scanf("%d \n", &N);
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = ((fac[i-1]*i)%MOD+MOD)%MOD;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        scanf("%d ", &v[i]);
    sort(v.begin(), v.end());
    vector<vector<ll> > freq;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int f = v[i];
        int j;
        for (j = i; j < N; ++j) {
            if (v[j] == v[i])
                ++cnt;
            else
                break;
        }
        freq.push_back({1LL*f,1LL*cnt,1LL*(j-i)});
        --j;
        i = j;
    }
    for (int i = freq.size()-1; i >= 1; --i) {
        freq[i][1] = freq[i-1][1];
    }
    freq[0][1] = 0;
    ll res = 0;
    for (int i = 0; i < freq.size(); ++i) {
        ll fx = freq[i][1];
        if (fx == N-1)
            continue;
        ll cur = fac[N];
        cur *= raise(N-fx, MOD-2);
        cur = (cur%MOD+MOD)%MOD;
        cur *= freq[i][2];
        cur = (cur%MOD+MOD)%MOD;
        cur *= freq[i][0];
        cur = (cur%MOD+MOD)%MOD;
        res += cur;
        res = (res%MOD+MOD)%MOD;
    }
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6+5;

ll fac[MAXN];
const ll MOD = 1e9+7;

ll raise(ll a, ll p) {
    if (p == 0)
        return 1;
    ll cur = raise(a, p/2)%MOD;
    cur = (cur*cur)%MOD;
    if (p%2)
        return (cur*a)%MOD;
    else
        return cur;
}

int main() {
    int N; scanf("%d \n", &N);
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = (fac[i-1]*i)%MOD;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        scanf("%d ", &v[i]);
    sort(v.begin(), v.end());
    vector<vector<ll> > freq;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int f = v[i];
        int j;
        for (j = i; j < N; ++j) {
            if (v[j] == v[i])
                ++cnt;
            else
                break;
        }
        freq.push_back({1LL*f,1LL*cnt,j-i});
        --j;
        i = j;
    }
    for (int i = freq.size()-1; i >= 1; --i) {
        freq[i][1] = freq[i-1][1];
    }
    freq[0][1] = 0;
    ll res = 0;
    for (int i = 0; i < freq.size(); ++i) {
        ll fx = freq[i][1];
        if (fx == N-1)
            continue;
        ll cur = fac[N];
        cur *= raise(N-fx, MOD-2);
        cur %= MOD;
        cur *= freq[i][2];
        cur %= MOD;
        cur *= freq[i][0];
        cur %= MOD;
        res += cur;
        res %= MOD;
    }
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6+5;

ll fac[MAXN];
const ll MOD = 1e9+7;

ll raise(ll a, ll p) {
    if (p == 0)
        return 1;
    ll cur = raise(a, p/2)%MOD;
    cur = (cur*cur)%MOD;
    if (p%2)
        return (cur*a)%MOD;
    else
        return cur;
}

int main() {
    int N; scanf("%d \n", &N);
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = ((fac[i-1]*i)%MOD+MOD)%MOD;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        scanf("%d ", &v[i]);
    sort(v.begin(), v.end());
    int fx = 0;
    int cnt = 0;
    ll res = 0;
    for (int i = 0; i < N; ++i) {
        int f = v[i];
        if (i && v[i-1] != f) {
            fx += cnt;
            cnt = 1;
        }
        else
            ++cnt;
        if (fx == N-1)
            continue;
        ll cur = fac[N];
        cur *= raise(N-fx, MOD-2);
        cur = (cur%MOD+MOD)%MOD;
        cur *= f;
        cur = (cur%MOD+MOD)%MOD;
        res += cur;
        res = (res%MOD+MOD)%MOD;
    }
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6+5;

ll fac[MAXN];
const ll MOD = 1e9+7;

ll raise(ll a, ll p) {
    if (p == 0)
        return 1;
    ll cur = raise(a, p/2)%MOD;
    cur = (cur*cur)%MOD;
    if (p%2)
        return (cur*a)%MOD;
    else
        return cur;
}

int main() {
    int N; scanf("%d \n", &N);
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = ((fac[i-1]*i)%MOD+MOD)%MOD;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        scanf("%d ", &v[i]);
    sort(v.begin(), v.end());
    int fx = 0;
    int cnt = 0;
    ll res = 0;
    for (int i = 0; i < N; ++i) {
        int f = v[i];
        if (i && v[i-1] != f) {
            fx += cnt;
            cnt = 0;
        }
        else
            ++cnt;
        if (fx == N-1)
            continue;
        ll cur = fac[N];
        cur *= raise(N-fx, MOD-2);
        cur = (cur%MOD+MOD)%MOD;
        cur *= f;
        cur = (cur%MOD+MOD)%MOD;
        res += cur;
        res = (res%MOD+MOD)%MOD;
    }
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6+5;

ll fac[MAXN];
const ll MOD = 1e9+7;

ll raise(ll a, ll p) {
    if (p == 0)
        return 1;
    ll cur = raise(a, p/2)%MOD;
    cur = (cur*cur)%MOD;
    if (p%2)
        return (cur*a)%MOD;
    else
        return cur;
}

int main() {
    int N; scanf("%d \n", &N);
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = ((fac[i-1]*i)%MOD+MOD)%MOD;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        scanf("%d ", &v[i]);
    sort(v.begin(), v.end());
    int fx = 0;
    int cnt = 0;
    ll res = 0;
    for (int i = 0; i < N; ++i) {
        int f = v[i];
        if (i && v[i-1] != f) {
            fx += cnt;
            cnt = 1;
        }
        else
            ++cnt;
        if (f == v[N-1])
            continue;
        ll cur = fac[N];
        cur *= raise(N-fx, MOD-2);
        cur = (cur%MOD+MOD)%MOD;
        cur *= f;
        cur = (cur%MOD+MOD)%MOD;
        res += cur;
        res = (res%MOD+MOD)%MOD;
    }
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6+5;

ll fac[MAXN];
const ll MOD = 1e9+7;

ll raise(ll a, ll p) {
    if (p == 0)
        return 1;
    ll cur = raise(a, p/2)%MOD;
    cur = (cur*cur)%MOD;
    if (p%2)
        return (cur*a)%MOD;
    else
        return cur;
}

int main() {
    int N; scanf("%d \n", &N);
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = (fac[i-1]*i)%MOD;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        scanf("%d ", &v[i]);
    sort(v.begin(), v.end());
    vector<vector<ll> > freq;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int f = v[i];
        int j;
        for (j = i; j < N; ++j) {
            if (v[j] == v[i])
                ++cnt;
            else
                break;
        }
        freq.push_back({1LL*f,1LL*cnt,1LL*(j-i)});
        --j;
        i = j;
    }
    for (int i = freq.size()-1; i >= 1; --i) {
        freq[i][1] = freq[i-1][1];
    }
    freq[0][1] = 0;
    ll res = 0;
    for (int i = 0; i < freq.size(); ++i) {
        ll fx = freq[i][1];
        if (fx == N-1)
            continue;
        ll cur = fac[N];
        cur *= raise(N-fx, MOD-2);
        cur %= MOD;
        cur *= freq[i][2];
        cur %= MOD;
        cur *= freq[i][0];
        cur %= MOD;
        res += cur;
        res %= MOD;
    }
    cout << res;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6+5;

ll fac[MAXN];
const ll MOD = 1e9+7;

ll raise(ll a, ll p) {
    if (p == 0)
        return 1;
    ll cur = raise(a, p/2)%MOD;
    cur = (cur*cur)%MOD;
    if (p%2)
        return (cur*a)%MOD;
    else
        return cur;
}

int main() {
    int N; scanf("%d \n", &N);
    fac[0] = 1;
    for (int i = 1; i <= N; ++i)
        fac[i] = ((fac[i-1]*i)%MOD+MOD)%MOD;
    vector<int> v(N);
    for (int i = 0; i < N; ++i)
        scanf("%d ", &v[i]);
    sort(v.begin(), v.end());
    vector<vector<ll> > freq;
    int fx = 0;
    int cnt = 1;
    ll res = 0;
    for (int i = 0; i < N; ++i) {
        int f = v[i];
        if (i && v[i-1] != f)
            fx += cnt;
        else
            ++cnt;
        ll cur = fac[N];
        cur *= raise(N-fx, MOD-2);
        cur = (cur%MOD+MOD)%MOD;
        cur *= f;
        cur = (cur%MOD+MOD)%MOD;
        res += cur;
        res = (res%MOD+MOD)%MOD;
    }
    cout << res;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll tot,mod=1e9+7;
ll jc[1000500];
ll s[1000050];
ll b[1000050];
ll cal(ll g,ll x)
{
    ll ans=1;
    while(g)
    {
        if(g&1) ans=(ans*x)%mod;
        x=(x*x)%mod;
        g>>=1;
    }
    return ans;
}
int main()
{
	jc[0]=1;jc[1]=1;
	for(int i=2;i<1000018;i++){
		jc[i]=i*1ll*jc[i-1]%mod;}
	scanf("%lld",&tot);
	for(int i=1;i<=tot;i++)
		scanf("%lld",&s[i]);
	sort(s+1,s+tot+1);
	ll ans=0;
	for(int i=1;i<tot;i++){
		if(s[i]==s[i-1])
			b[i]=b[i-1];
		else
			b[i]=i-1;
		ans+=s[i]*jc[tot]*cal(mod-2,tot-b[i])%mod;
		ans%=mod;
	}
	printf("%lld",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,oppo[1000005],ans;
int main()
{
	cin>>n;
	int f=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&oppo[i]);
		f*=i;
	}
	sort(oppo+1,oppo+n+1);
	for(int i=1;i<n;i++)
	{
		int j=i;
		while(oppo[j-1]==oppo[j])
			j--;
		ans+=oppo[j]*f/(n-(j-1));
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=100000007;
long long ans,k=1;
int n,a[1000003],l[1000003],f[1000003];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)scanf("%d",a+i);
	f[0]=1;
	for(int i=1;i<1000003;i++)f[i]=f[i-1]*i%mod;
	sort(a,a+n);
	for(int i=0,j=0;i<n;i++){while(a[j]<a[i])j++;l[i]=j;}
	int j=n;
	for(int i=0;i+1<n;i++)
	{
		while(j>n-l[i]+1)k=(k*j--)%mod;
		ans=(ans+(a[i]*k%mod)*f[n-l[i]-1])%mod;
	}
	cout<<ans;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 1000005
#define mod 1000000007LL
#define ll long long
using namespace std;
ll n,a[maxn],ans=0,inv[maxn],jc[maxn];
inline void init(){
    inv[0]=inv[1]=1;
    for(ll i=2;i<=n;i++)inv[i]=((mod-mod/i)*inv[mod%i])%mod;
    jc[0]=jc[1]=1;
    for(ll i=2;i<=n;i++)jc[i]=(jc[i-1]*i)%mod;
}
int main(){
    scanf("%lld",&n);
    init();
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    ll pos=1;
    while(pos<=n){
        ll poss=upper_bound(a+1,a+n+1,a[pos])-a;
        if(poss<=n)ans=(ans+jc[n]*inv[n-pos+1]%mod*a[pos]%mod*(poss-pos)%mod)%mod;
        pos=poss;
    }
    printf("%lld\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1000000+5;
typedef long long ll;
const int p=1e9+7;
int n;
ll f[N],a[N];
ll mog(ll a,int b)
{
	ll ans=1;
	while(b){
		if(b&1) ans=ans*a%p;
		b>>=1;a=a*a%p;
	}
	return ans;
}
int main()
{
	cin>>n;
	f[0]=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		f[i]=f[i-1]*i%p;
	}
	sort(a+1,a+1+n);
	int END=a[n];
	ll ans=0;int x=0;
	for(int i=1;i<=n&&a[i]!=END;i++)
	{
		if(a[i]!=a[i-1])x=i-1;
		ans=(ans+a[i]*f[n]%p*mog(n-x,p-2))%p;
	}
	cout<<ans%p<<endl;
	return 0;
}


/*
1.前面没有大于等于他的
2.  f[i]=(i-1)!*(n-i+1)!*C(i-1,n)=n!/(n-i+1)
*/
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
inline int read(){int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}
inline void write(int x){if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10); putchar(x%10+'0');}
inline void writeln(int x){write(x); puts("");}
const int mod=1e9+7,N=1e6+5;
inline int Pow(int x,int k){
    int y=1;
    for (;k;k>>=1,x=x*x%mod) if (k&1) y=y*x%mod;
    return y;
}
int n,tmp,a[N];
inline void init(){
    n=read(); tmp=1;
    for (int i=1;i<=n;i++) {
        tmp=tmp*i%mod;
    }
    for (int i=1;i<=n;i++){
        a[i]=read();
    }
}
int ans,now;
inline void solve(){
    sort(a+1,a+1+n);
    for (int i=1;i<=n;i=now){
        now=i;
        while (now<=n&&a[i]==a[now]) now++;
        if (now<=n) ans=(ans+tmp*Pow(n-i+1,mod-2)%mod*(now-i)%mod*a[i]%mod)%mod;
    }
    writeln(ans);
}
signed main(){
    init();
    solve();
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;

int n;
int a[1000010];

long long ksm(long long a,long long b)
{
	long long ret=1;
	while(b)
	{
		if(b&1)
			ret=ret*a%1000000007;
		a=a*a%1000000007;
		b>>=1;
	}
	return ret;
}

long long A=1,ans;

int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		A=A*i%1000000007;
	}
	sort(a+1,a+1+n);
	int pos;
	for(int i=1; i<=n; i=pos)
	{
		pos=i;
		while(a[i]==a[pos] && pos<=n) pos++;
		if(pos<=n)
			ans=(ans+A*ksm(n-i+1,1000000007-2)%1000000007*(pos-i)%1000000007*a[i]%1000000007)%1000000007;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll tot,mod=1e9+7;
ll jc[1000500];
ll s[1000050];
ll b[1000050];
ll cal(ll g,ll x)
{
    ll ans=1;
    while(g)
    {
        if(g&1) ans=(ans*x)%mod;
        x=(x*x)%mod;
        g>>=1;
    }
    return ans;
}
int main()
{
	jc[0]=1;jc[1]=1;
	for(int i=2;i<1000018;i++){
		jc[i]=i*1ll*jc[i-1]%mod;}
	scanf("%lld",&tot);
	for(int i=1;i<=tot;i++)
		scanf("%lld",&s[i]);
	sort(s+1,s+tot+1);
	ll ans=0;
	ll yq=0;
	for(int i=1;i<tot;i++){
		if(s[i]==s[i-1]){
			ans+=yq;
			ans%=mod;
			continue;
		}
		else
			b[i]=i-1;
		yq=s[i]*jc[tot]*cal(mod-2,tot-b[i])%mod;
		ans+=yq;
		ans%=mod;
	}
	printf("%lld",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long a[1000010];
long long n,ans,A,MO=1e9+7,rec;
long long qsm(long long x,long long k)
{
	long long cnt=1;
	while(k)
	{
		if (k&1) cnt=(cnt*x)%MO;
		x=(x*x)%MO;k>>=1;
	}
	return cnt;
}
int main()
{
	scanf("%lld",&n);A=1;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=2;i<=n;i++) A=(A*i)%MO;
	sort(a+1,a+n+1);
	for(long long i=1;i<=n;i=rec)
	{
		rec=i;
		while(a[i]==a[rec]&&rec<=n) rec++;
		if (rec<=n) ans=(ans+MO+(A*qsm(n-i+1,MO-2))%MO*(rec-i)%MO*a[i]%MO)%MO;
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll n,a[1000500],b[1005000],pp,ans;
ll ksm(ll a,ll b){
	ll c=1;
	while(b){
		if(b&1) c=(c*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return c;
}
int main(){
	cin>>n;
	pp=1;
	for(int i=1;i<=n;i++){
		pp=pp*i%mod;
		cin>>a[i];
	}
	sort(a+1,a+n+1);int x=0;
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1]) x=i-1;
		ans=(ans+(a[i]*pp%mod*ksm(n-x,mod-2))%mod)%mod;
	}
	cout<<ans%mod<<endl;
	return 0;
}
/**
*　　┏┓　　　┏┓+ +
*　┏┛┻━━━┛┻┓ + +
*　┃　　　　　　　┃
*　┃　　　━　　　┃ ++ + + +
*  ████━████+
*  ◥██◤　◥██◤ +
*　┃　　　┻　　　┃
*　┃　　　　　　　┃ + +
*　┗━┓　　　┏━┛
*　　　┃　　　┃ + + + +Code is far away from
*　　　┃　　　┃ + bug with the animal protecting
*　　　┃　 　 ┗━━━┓ 神兽保佑,代码无bug
*　　　┃ 　　　　　　 ┣┓
*　　  ┃ 　　　　　 　┏┛
*　    ┗┓┓┏━┳┓┏┛ + + + +
*　　　　┃┫┫　┃┫┫
*　　　　┗┻┛　┗┻┛+ + + +
*/


#include<bits/stdc++.h>
#define N 1000010
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll n,a[N],ans,JC[N];
inline ll Quick_pow(ll a,ll b)
{
	ll res=1;
	while(b){
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main()
{
	scanf("%lld",&n);
	JC[0]=JC[1]=1;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		JC[i]=JC[i-1]*i%mod;
	}
	sort(a+1,a+1+n);
	int x=0;
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1])
			x=i-1;
		ans=(ans+a[i]*JC[n]%mod*Quick_pow(n-x,mod-2))%mod;
	}
	printf("%lld\n",ans%mod);
	return 0;
}
/*
*
*　　┏┓　　　┏┓+ +
*　┏┛┻━━━┛┻┓ + +
*　┃　　　　　　　┃
*　┃　　　━　　　┃ ++ + + +
*  ████━████+
*  ◥██◤　◥██◤ +
*　┃　　　┻　　　┃
*　┃　　　　　　　┃ + +
*　┗━┓　　　┏━┛
*　　　┃　　　┃ + + + +Code is far away from
*　　　┃　　　┃ + bug with the animal protecting
*　　　┃　 　 ┗━━━┓ 神兽保佑,代码无bug
*　　　┃ 　　　　　　 ┣┓
*　　  ┃ 　　　　　 　┏┛
*　    ┗┓┓┏━┳┓┏┛ + + + +
*　　　　┃┫┫　┃┫┫
*　　　　┗┻┛　┗┻┛+ + + +
*/


#include<bits/stdc++.h>
#define N 1000010
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll n,a[N],ans,JC[N],MAX;
inline ll Quick_pow(ll a,ll b)
{
	ll res=1;
	while(b){
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main()
{
	scanf("%lld",&n);
	JC[0]=JC[1]=1;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		JC[i]=JC[i-1]*i%mod;
	}
	sort(a+1,a+1+n);
	int x=0;
	MAX=a[n];
	for(int i=1;i<=n&&a[i]!=MAX;i++){
		if(a[i]!=a[i-1])
			x=i-1;
		ans=(ans+a[i]*JC[n]%mod*Quick_pow(n-x,mod-2))%mod;
	}
	printf("%lld\n",ans%mod);
	return 0;
}
/*
*
*　　┏┓　　　┏┓+ +
*　┏┛┻━━━┛┻┓ + +
*　┃　　　　　　　┃
*　┃　　　━　　　┃ ++ + + +
*  ████━████+
*  ◥██◤　◥██◤ +
*　┃　　　┻　　　┃
*　┃　　　　　　　┃ + +
*　┗━┓　　　┏━┛
*　　　┃　　　┃ + + + +Code is far away from
*　　　┃　　　┃ + bug with the animal protecting
*　　　┃　 　 ┗━━━┓ 神兽保佑,代码无bug
*　　　┃ 　　　　　　 ┣┓
*　　  ┃ 　　　　　 　┏┛
*　    ┗┓┓┏━┳┓┏┛ + + + +
*　　　　┃┫┫　┃┫┫
*　　　　┗┻┛　┗┻┛+ + + +
*/


#include<bits/stdc++.h>
#define MAXN 1000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,a[MAXN];
ll fact[MAXN];
ll extgcd(ll a,ll b,ll &x,ll &y)
{
    ll d=a;
    if(b!=0)
    {
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else
    {
        x=1;
        y=0;
    }
    return d;
}
ll mod_inverse(ll a,ll m)
{
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
int main()
{
	fact[0]=1;
	for(ll i=1;i<MAXN;i++)
		fact[i]=fact[i-1]*i%MOD;
	scanf("%I64d",&n);
	for(ll i=0;i<n;i++)
		scanf("%I64d",&a[i]);
	ll cnt=0,res=0;
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(i==0||a[i]==a[i-1])
		{
			res++;
		}
		else {cnt+=res; res=1;}
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(cnt!=n-1) ans=(ans+(a[i]*(fact[n]*mod_inverse(n-cnt,MOD)%MOD)%MOD))%MOD;
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,a[MAXN];
ll fact[MAXN];
ll extgcd(ll a,ll b,ll &x,ll &y)
{
    ll d=a;
    if(b!=0)
    {
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else
    {
        x=1;
        y=0;
    }
    return d;
}
ll mod_inverse(ll a,ll m)
{
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
int main()
{
	fact[0]=1;
	for(ll i=1;i<MAXN;i++)
		fact[i]=fact[i-1]*i%MOD;
	scanf("%I64d",&n);
	ll maxi=-1;
	for(ll i=0;i<n;i++)
	{
		scanf("%I64d",&a[i]);
		maxi=max(maxi,a[i]);
	}
	ll cnt=0,res=0;
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(i==0||a[i]==a[i-1])
		{
			res++;
		}
		else {cnt+=res; res=1;}
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(a[i]!=maxi) ans=(ans+(a[i]*(fact[n]*mod_inverse(n-cnt,MOD)%MOD)%MOD))%MOD;
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,a[MAXN];
ll fact[MAXN];
ll extgcd(ll a,ll b,ll &x,ll &y)
{
    ll d=a;
    if(b!=0)
    {
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else
    {
        x=1;
        y=0;
    }
    return d;
}
ll mod_inverse(ll a,ll m)
{
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
int main()
{
	fact[0]=1;
	for(ll i=1;i<MAXN;i++)
		fact[i]=fact[i-1]*i%MOD;
	scanf("%I64d",&n);
	for(ll i=0;i<n;i++)
		scanf("%I64d",&a[i]);
	ll cnt=0,res=0;
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(i==0||a[i]==a[i-1])
		{
			res++;
		}
		else {cnt+=res; res=1;}
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(cnt!=n-1) ans=(ans+(fact[n]*mod_inverse(n-cnt,MOD)%MOD))%MOD;
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 1000005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,k,a[MAXN];
ll fact[MAXN];
ll extgcd(ll a,ll b,ll &x,ll &y)
{
    ll d=a;
    if(b!=0)
    {
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else
    {
        x=1;
        y=0;
    }
    return d;
}
ll mod_inverse(ll a,ll m)
{
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
int main()
{
	fact[0]=1;
	for(ll i=1;i<MAXN;i++)
		fact[i]=fact[i-1]*i%MOD;
	scanf("%I64d",&n);
	for(ll i=0;i<n;i++)
		scanf("%I64d",&a[i]);
	ll cnt=0,res=0;
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(i==0||a[i]==a[i-1])
		{
			res++;
		}
		else {cnt+=res+1; res=0;}
		//printf("%I64d %I64d %I64d\n",a[i],res,cnt);
		if(cnt!=n) ans=(ans+fact[n]*mod_inverse(n-cnt,MOD)%MOD)%MOD;
	}
	printf("%I64d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define IOS ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
inline int in(){int32_t x ; scanf("%d",&x) ; return x ;}
inline long long lin(){long long x ; scanf("%lld",&x) ; return x;}
const int maxn = 1000 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9 ;
const long long infll = 1e18;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
inline int power(int a , int b) {return b == 0 ? 1 : power(a * a % mod , b >> 1) * (b % 2 ? a : 1) % mod ;}
int a[maxn];
int fact[maxn],inv[maxn];
inline int choose(int n , int r)
{
	if (r < 0 || n < r) return 0 ;
	return fact[n]*inv[r]%mod*inv[n-r]%mod;

}
int32_t main()
{
	int n = in();
	for (int i = 0 ; i < n ; i ++)
		a[i] = in();
	sort(a,a+n);
	fact[0] = inv[0] =  1;
	for (int i = 1 ; i <= n ; i ++)
	{
		fact[i] = fact[i- 1] * i % mod;
		inv[i] = inv[i - 1] * power(i,mod-2)%mod;
	}
	int res = 0;
	for (int i = 0 ; i < n - 1 ; i++)
	{

		int j = i;
		while(j + 1 < n && a[j + 1] == a[j]) j ++;
		int cnt = j - i + 1;
		if (j == n - 1) break;
		int greater = n - j - 1;
		int cc = choose(n,greater+cnt);
		(cc *= fact[n-greater-cnt]);
		(res += cc* cnt % mod * fact[greater+cnt-1] % mod * a[i])%=mod;
		i = j;
		/*
		int greater = n - i - 1;

		int CC = choose(n,greater+1);
		(CC *= fact[greater])%=mod;
		(CC  *= fact[n-greater-1])%mod;
		(res += CC * a[i]%mod)%=mod;
		*/
	}
	cout << res << endl;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define IOS ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
inline int in(){int32_t x ; scanf("%d",&x) ; return x ;}
inline long long lin(){long long x ; scanf("%lld",&x) ; return x;}
const int maxn = 2e6 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9 ;
const long long infll = 1e18;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
inline int power(int a , int b) {return b == 0 ? 1 : power(a * a % mod , b >> 1) * (b % 2 ? a : 1) % mod ;}
int a[maxn];
int fact[maxn],inv[maxn];
inline int choose(int n , int r)
{
	if (r < 0 || n < r) return 0 ;
	return fact[n]*inv[r]%mod*inv[n-r]%mod;

}
int32_t main()
{
	int n = in();
	for (int i = 0 ; i < n ; i ++)
		a[i] = in();
	sort(a,a+n);
	fact[0] = inv[0] =  1;
	for (int i = 1 ; i <= n ; i ++)
	{
		fact[i] = fact[i- 1] * i % mod;
		inv[i] = inv[i - 1] * power(i,mod-2)%mod;
	}
	int res = 0;
	for (int i = 0 ; i < n - 1 ; i++)
	{

		int j = i;
		while(j + 1 < n && a[j + 1] == a[j]) j ++;
		int cnt = j - i + 1;
		if (j == n - 1) break;
		int greater = n - j - 1;
		int cc = choose(n,greater+cnt);
		(cc *= fact[n-greater-cnt]);
		(res += cc* cnt % mod * fact[greater+cnt-1] % mod * a[i])%=mod;
		i = j;
		/*
		int greater = n - i - 1;

		int CC = choose(n,greater+1);
		(CC *= fact[greater])%=mod;
		(CC  *= fact[n-greater-1])%mod;
		(res += CC * a[i]%mod)%=mod;
		*/
	}
	cout << res << endl;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define IOS ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
inline int in(){int32_t x ; scanf("%d",&x) ; return x ;}
inline long long lin(){long long x ; scanf("%lld",&x) ; return x;}
const int maxn = 1000 + 10;
const int mod = 1e9 + 7;
const int inf = 1e9 ;
const long long infll = 1e18;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
inline int power(int a , int b) {return b == 0 ? 1 : power(a * a % mod , b >> 1) * (b % 2 ? a : 1) % mod ;}
int a[maxn];
int fact[maxn],inv[maxn];
inline int choose(int n , int r)
{
	if (r < 0 || n < r) return 0 ;
	return fact[n]*inv[r]%mod*inv[n-r]%mod;

}
int suf[maxn];
int32_t main()
{
	int n = in();
	for (int i = 0 ; i < n ; i ++)
		a[i] = in();
	sort(a,a+n);
	fact[0] = inv[0] =  1;
	suf[n] = 1;

	for (int i = 1 ; i <= n ; i ++)
	{
		fact[i] = fact[i- 1] * i % mod;
		inv[i] = inv[i - 1] * power(i,mod-2)%mod;
	}
	for (int i = n - 1 ; i >= 0 ; i --)
	{
		int j = i ;
		while(j && a[j - 1] == a[j]) j --;
		int cnt = i - j + 1;
		suf[j] = suf[i + 1] * inv[cnt] % mod;
		i = j;
	}
	int res = 0;
	for (int i = 0 ; i < n - 1 ; i++)
	{

		int j = i;
		while(j + 1 < n && a[j + 1] == a[j]) j ++;
		int cnt = j - i + 1;
		if (j == n - 1) break;
		int greater = n - j - 1;
		int cc = choose(n,greater+cnt);
		int divide = suf[j + 1] * inv[cnt - 1] % mod;
		(cc *= fact[n-greater-cnt]);
		(res += cc * divide % mod * cnt % mod * fact[greater+cnt-1] % mod)%=mod;
		i = j;
		/*
		int greater = n - i - 1;

		int CC = choose(n,greater+1);
		(CC *= fact[greater])%=mod;
		(CC  *= fact[n-greater-1])%mod;
		(res += CC * a[i]%mod)%=mod;
		*/
	}
	cout << res << endl;
}


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

/*
typedef long long i64;
vector <pair <int, i64>> adia[200010];

i64 cost[200010];
*/
int put2[1000010];
int v[1000010];
int fact[1000010];

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i(0); i < n; i++)
        cin >> v[i];

    sort(v, v + n);

    int nrlast(0), nract(0), vact(-1e9);
    int ans(0);

    put2[0] = 1;
    fact[0] = 1;
    for (int i(1); i <= n; i++) {
        put2[i] = 2ll * put2[i - 1] % mod;
        fact[i] = 1ll * i * fact[i - 1] % mod;
    }

    for (int i(0); i < n; i++) {
        if (v[i] != vact) {
            if (nract != 0) {
              ans = (ans +
                1ll * vact * nract % mod * fact[nrlast] % mod * fact[n - nrlast - 1]) % mod;
            }

            vact = v[i], nrlast += nract, nract = 1;
        }
        else
            nract++;
    }

    cout << ans << '\n';
    /*
    int n, m, a, b;
    i64 c;
    cin >> n >> m;

    while (m--) {
        cin >> a >> b >> c;
        adia[a].push_back({ b, 2 * c });
        adia[b].push_back({ a, 2 * c });
    }

    priority_queue <pair <i64, int>> q;

    for (int i(1); i <= n; i++) {
        cin >> cost[i];
        q.push({ -cost[i], i });
    }

    while (!q.empty()) {
        int n = q.top().second;
        if (q.top().first != -cost[n]) {
            q.pop();
            continue;
        }
        q.pop();

        for (auto i : adia[n]) {
            if (cost[i.first] > cost[n] + i.second) {
                cost[i.first] = cost[n] + i.second;
                q.push({ -cost[i.first], i.first });
            }
        }
    }

    for (int i(1); i <= n; i++)
        cout << cost[i] << ' ';

    /*
    int t, q;

    cin >> t;

    while (t--) {
        cin >> q;
        if (q == 0) {
            cout << "1 1\n";
            continue;
        }

        bool told = 0;
        for (int i(1); i * i < q; i++) {
            if (q % i == 0) {
                int a = i, b = q / i;
                if ((a + b) % 2 == 1)
                    continue;
                int n = (a + b) / 2, m = (b - a) / 2;
                if (1ll * n * n - 1ll * m * m != q)
                    continue;
                int x = n / m;
                if (n / x != m)
                    continue;
                cout << n << ' ' << x << '\n';
                told = 1;
                break;
            }
        }
        if (!told)
            cout << -1 << '\n';
    }

 /*   vector <int> v;
    int n;
    cin >> n;
    v.resize(n + 2);

    for (int i(1); i <= n; i++)
        cin >> v[i];
    v[0] = 1, v[n + 1] = 1000000;
    int best(1e9);

    for (int i(0); i <= n; i++) {
        best = min(best, max(v[i] - 1, 1000000 - v[i + 1]));
    }

    cout << best << '\n';
/*
    int x;
    cin >> x;
    string s;
    cin >> s;
    char last = '1';
    for (auto i : s) {
        if (i == 'a' || i == 'e' || i == 'i' || i == 'o' || i == 'u' || i == 'y') {
            if (last == 'a' || last == 'e' || last == 'i' || last == 'o' || last == 'u' || last == 'y')
                continue;
            last = i;
            cout << last;
        }
        else {
            last = i;
            cout << last;
        }
    }*/
    return 0;
}


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

/*
typedef long long i64;
vector <pair <int, i64>> adia[200010];

i64 cost[200010];
*/
int put2[2000010];
int v[2000010];
int fact[2000010];
int invfact[2000010];

int put(int x, int p)
{
    int ans(1);
    while (p) {
        if (p & 1)
            ans = 1ll * x * ans % mod;
        x = 1ll * x * x % mod;
        p /= 2;
    }
    return ans;
}

int comb(int a, int b)
{
    if (a < b || b < 0)
        return 0;
    return fact[a] * invfact[b] % mod * invfact[a - b] % mod;
}

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i(0); i < n; i++)
        cin >> v[i];

    sort(v, v + n);

    int nrlast(0), nract(0), vact(-1e9);
    int ans(0);

    //put2[0] = 1;
    fact[0] = 1;
    for (int i(1); i <= 2000000; i++) {
        //put2[i] = 2ll * put2[i - 1] % mod;
        fact[i] = 1ll * i * fact[i - 1] % mod;
    }
    invfact[2000000] = put(fact[2000000], mod - 2);
    for (int i(1999999); i >= 0; i--)
        invfact[i] = 1ll * (i + 1) * invfact[i + 1] % mod;

    for (int i(0); i < n; i++) {
        if (v[i] != vact) {
            if (nract != 0) {
              ans = (ans +
                1ll * vact * nract % mod * fact[nrlast] % mod * fact[n - nrlast - 1] % mod * comb(n, nrlast)) % mod;
            }

            vact = v[i], nrlast += nract, nract = 1;
        }
        else
            nract++;
    }

    cout << ans << '\n';
    /*
    int n, m, a, b;
    i64 c;
    cin >> n >> m;

    while (m--) {
        cin >> a >> b >> c;
        adia[a].push_back({ b, 2 * c });
        adia[b].push_back({ a, 2 * c });
    }

    priority_queue <pair <i64, int>> q;

    for (int i(1); i <= n; i++) {
        cin >> cost[i];
        q.push({ -cost[i], i });
    }

    while (!q.empty()) {
        int n = q.top().second;
        if (q.top().first != -cost[n]) {
            q.pop();
            continue;
        }
        q.pop();

        for (auto i : adia[n]) {
            if (cost[i.first] > cost[n] + i.second) {
                cost[i.first] = cost[n] + i.second;
                q.push({ -cost[i.first], i.first });
            }
        }
    }

    for (int i(1); i <= n; i++)
        cout << cost[i] << ' ';

    /*
    int t, q;

    cin >> t;

    while (t--) {
        cin >> q;
        if (q == 0) {
            cout << "1 1\n";
            continue;
        }

        bool told = 0;
        for (int i(1); i * i < q; i++) {
            if (q % i == 0) {
                int a = i, b = q / i;
                if ((a + b) % 2 == 1)
                    continue;
                int n = (a + b) / 2, m = (b - a) / 2;
                if (1ll * n * n - 1ll * m * m != q)
                    continue;
                int x = n / m;
                if (n / x != m)
                    continue;
                cout << n << ' ' << x << '\n';
                told = 1;
                break;
            }
        }
        if (!told)
            cout << -1 << '\n';
    }

 /*   vector <int> v;
    int n;
    cin >> n;
    v.resize(n + 2);

    for (int i(1); i <= n; i++)
        cin >> v[i];
    v[0] = 1, v[n + 1] = 1000000;
    int best(1e9);

    for (int i(0); i <= n; i++) {
        best = min(best, max(v[i] - 1, 1000000 - v[i + 1]));
    }

    cout << best << '\n';
/*
    int x;
    cin >> x;
    string s;
    cin >> s;
    char last = '1';
    for (auto i : s) {
        if (i == 'a' || i == 'e' || i == 'i' || i == 'o' || i == 'u' || i == 'y') {
            if (last == 'a' || last == 'e' || last == 'i' || last == 'o' || last == 'u' || last == 'y')
                continue;
            last = i;
            cout << last;
        }
        else {
            last = i;
            cout << last;
        }
    }*/
    return 0;
}


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

/*
typedef long long i64;
vector <pair <int, i64>> adia[200010];

i64 cost[200010];
*/
int put2[1000010];
int v[1000010];
int fact[1000010];

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i(0); i < n; i++)
        cin >> v[i];

    sort(v, v + n);

    int nrlast(0), nract(0), vact(-1e9);
    int ans(0);

    put2[0] = 1;
    fact[0] = 1;
    for (int i(1); i <= n; i++) {
        put2[i] = 2ll * put2[i - 1] % mod;
        fact[i] = 1ll * i * fact[i - 1] % mod;
    }

    for (int i(0); i < n; i++) {
        if (v[i] != vact) {
            if (nract != 0) {
                ans = (ans + 1ll * vact * nract % mod * fact[nrlast] % mod * fact[nract] % mod * fact[n - nrlast - nract]) % mod;
            }

            vact = v[i], nrlast += nract, nract = 1;
        }
        else
            nract++;
    }

    cout << ans << '\n';
    /*
    int n, m, a, b;
    i64 c;
    cin >> n >> m;

    while (m--) {
        cin >> a >> b >> c;
        adia[a].push_back({ b, 2 * c });
        adia[b].push_back({ a, 2 * c });
    }

    priority_queue <pair <i64, int>> q;

    for (int i(1); i <= n; i++) {
        cin >> cost[i];
        q.push({ -cost[i], i });
    }

    while (!q.empty()) {
        int n = q.top().second;
        if (q.top().first != -cost[n]) {
            q.pop();
            continue;
        }
        q.pop();

        for (auto i : adia[n]) {
            if (cost[i.first] > cost[n] + i.second) {
                cost[i.first] = cost[n] + i.second;
                q.push({ -cost[i.first], i.first });
            }
        }
    }

    for (int i(1); i <= n; i++)
        cout << cost[i] << ' ';

    /*
    int t, q;

    cin >> t;

    while (t--) {
        cin >> q;
        if (q == 0) {
            cout << "1 1\n";
            continue;
        }

        bool told = 0;
        for (int i(1); i * i < q; i++) {
            if (q % i == 0) {
                int a = i, b = q / i;
                if ((a + b) % 2 == 1)
                    continue;
                int n = (a + b) / 2, m = (b - a) / 2;
                if (1ll * n * n - 1ll * m * m != q)
                    continue;
                int x = n / m;
                if (n / x != m)
                    continue;
                cout << n << ' ' << x << '\n';
                told = 1;
                break;
            }
        }
        if (!told)
            cout << -1 << '\n';
    }

 /*   vector <int> v;
    int n;
    cin >> n;
    v.resize(n + 2);

    for (int i(1); i <= n; i++)
        cin >> v[i];
    v[0] = 1, v[n + 1] = 1000000;
    int best(1e9);

    for (int i(0); i <= n; i++) {
        best = min(best, max(v[i] - 1, 1000000 - v[i + 1]));
    }

    cout << best << '\n';
/*
    int x;
    cin >> x;
    string s;
    cin >> s;
    char last = '1';
    for (auto i : s) {
        if (i == 'a' || i == 'e' || i == 'i' || i == 'o' || i == 'u' || i == 'y') {
            if (last == 'a' || last == 'e' || last == 'i' || last == 'o' || last == 'u' || last == 'y')
                continue;
            last = i;
            cout << last;
        }
        else {
            last = i;
            cout << last;
        }
    }*/
    return 0;
}


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

/*
typedef long long i64;
vector <pair <int, i64>> adia[200010];

i64 cost[200010];
*/
int put2[2000010];
int v[2000010];
int fact[2000010];
int invfact[2000010];

int put(int x, int p)
{
    int ans(1);
    while (p) {
        if (p & 1)
            ans = 1ll * x * ans % mod;
        x = 1ll * x * x % mod;
        p /= 2;
    }
    return ans;
}

int comb(int a, int b)
{
    if (a < b || b < 0)
        return 0;
    return 1ll * fact[a] * invfact[b] % mod * invfact[a - b] % mod;
}

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    for (int i(0); i < n; i++)
        cin >> v[i];

    sort(v, v + n);

    int nrlast(0), nract(0), vact(-1e9);
    int ans(0);

    //put2[0] = 1;
    fact[0] = 1;
    for (int i(1); i <= 2000000; i++) {
        //put2[i] = 2ll * put2[i - 1] % mod;
        fact[i] = 1ll * i * fact[i - 1] % mod;
    }
    invfact[2000000] = put(fact[2000000], mod - 2);
    for (int i(1999999); i >= 0; i--)
        invfact[i] = 1ll * (i + 1) * invfact[i + 1] % mod;

    //cout << comb(3, 2) << '\n';

    for (int i(0); i < n; i++) {
        if (v[i] != vact) {
            if (nract != 0) {
              ans = (ans +
                1ll * vact * nract % mod * fact[nrlast] % mod * fact[n - nrlast - 1] % mod * comb(n, nrlast)) % mod;
            }

            vact = v[i], nrlast += nract, nract = 1;
        }
        else
            nract++;
    }

    cout << ans << '\n';
    /*
    int n, m, a, b;
    i64 c;
    cin >> n >> m;

    while (m--) {
        cin >> a >> b >> c;
        adia[a].push_back({ b, 2 * c });
        adia[b].push_back({ a, 2 * c });
    }

    priority_queue <pair <i64, int>> q;

    for (int i(1); i <= n; i++) {
        cin >> cost[i];
        q.push({ -cost[i], i });
    }

    while (!q.empty()) {
        int n = q.top().second;
        if (q.top().first != -cost[n]) {
            q.pop();
            continue;
        }
        q.pop();

        for (auto i : adia[n]) {
            if (cost[i.first] > cost[n] + i.second) {
                cost[i.first] = cost[n] + i.second;
                q.push({ -cost[i.first], i.first });
            }
        }
    }

    for (int i(1); i <= n; i++)
        cout << cost[i] << ' ';

    /*
    int t, q;

    cin >> t;

    while (t--) {
        cin >> q;
        if (q == 0) {
            cout << "1 1\n";
            continue;
        }

        bool told = 0;
        for (int i(1); i * i < q; i++) {
            if (q % i == 0) {
                int a = i, b = q / i;
                if ((a + b) % 2 == 1)
                    continue;
                int n = (a + b) / 2, m = (b - a) / 2;
                if (1ll * n * n - 1ll * m * m != q)
                    continue;
                int x = n / m;
                if (n / x != m)
                    continue;
                cout << n << ' ' << x << '\n';
                told = 1;
                break;
            }
        }
        if (!told)
            cout << -1 << '\n';
    }

 /*   vector <int> v;
    int n;
    cin >> n;
    v.resize(n + 2);

    for (int i(1); i <= n; i++)
        cin >> v[i];
    v[0] = 1, v[n + 1] = 1000000;
    int best(1e9);

    for (int i(0); i <= n; i++) {
        best = min(best, max(v[i] - 1, 1000000 - v[i + 1]));
    }

    cout << best << '\n';
/*
    int x;
    cin >> x;
    string s;
    cin >> s;
    char last = '1';
    for (auto i : s) {
        if (i == 'a' || i == 'e' || i == 'i' || i == 'o' || i == 'u' || i == 'y') {
            if (last == 'a' || last == 'e' || last == 'i' || last == 'o' || last == 'u' || last == 'y')
                continue;
            last = i;
            cout << last;
        }
        else {
            last = i;
            cout << last;
        }
    }*/
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1000005,P = 10000007;
int n,fac[N];
map<int,int> mp;
int main ()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1;i <= n;i++)
    {
        int tmp;cin >> tmp;++mp[tmp];
    }
    fac[1] = 1;
    for (int i = 2;i <= n;i++) fac[i] = fac[i - 1] * 1ll * i % P;
    int cnt = 0;
    long long ans = 0;
    for (auto &i : mp)
    {
        ans = (ans + (cnt ? fac[cnt] : 1) * 1ll * fac[i.second ] % P *
            fac[n - i.second - cnt] % P * i.first % P * i.second % P) % P;
        cnt += i.second;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1000005,P = 1000000007;
int n,fac[N];
map<int,int,greater<int>> mp;
int qpow(int a,int b)
{
    int ret = 1;
    while (b)
    {
        if (b & 1) ret = ret * 1ll * a % P;
        a = a * 1ll * a % P;
        b >>= 1;
    }
    return ret;
}
int main ()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1;i <= n;i++)
    {
        int tmp;cin >> tmp;++mp[tmp];
    }
    fac[0] = 1;
    for (int i = 1;i <= n;i++) fac[i] = fac[i - 1] * 1ll * i % P;
    int cnt = 0;bool fs = 1;
    long long ans = 0;
    for (auto &i : mp)
    {
        cnt += i.second;
        if (!fs) ans += i.first * 1ll * fac[n] % P * i.second % P *
                qpow(cnt,P - 2) % P;
        else fs = 0;
        ans %= P;
    }
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
const LL M=1000000007;
int n,a[1000010];
LL fact[1000010],invf[1000010];

LL power(LL x,LL e)
{
    if(!e) return 1;
    LL t=power(x,e/2);
    if(e%2) return t*t%M*x%M;
    else return t*t%M;
}

int main()
{
    scanf("%d",&n);
    int i;
    for(fact[0]=1,i=1;i<=n;i++)
        fact[i]=fact[i-1]*i%M;
    for(invf[n]=power(fact[n],M-2),i=n-1;i>=0;i--)
        invf[i]=invf[i+1]*(i+1)%M;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    std::sort(a+1,a+n+1);
    LL ans=0;
    int x;
    for(a[0]=0,i=1;i<=n;i++)
    {
        if(a[i]!=a[i-1]) x=i;
        if(a[i]!=a[n])
            ans = ans + fact[x-1]*fact[n-x] %M *fact[n] %M *invf[x-1] %M *invf[n-x+1] %M;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
const LL M=1000000007;
int n,a[1000010];
LL fact[1000010],invf[1000010];

LL power(LL x,LL e)
{
    if(!e) return 1;
    LL t=power(x,e/2);
    if(e%2) return t*t%M*x%M;
    else return t*t%M;
}

int main()
{
    scanf("%d",&n);
    int i;
    for(fact[0]=1,i=1;i<=n;i++)
        fact[i]=fact[i-1]*i%M;
    for(invf[n]=power(fact[n],M-2),i=n-1;i>=0;i--)
        invf[i]=invf[i+1]*(i+1)%M;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    std::sort(a+1,a+n+1);
    LL ans=0;
    int x;
    for(a[0]=0,i=1;i<=n;i++)
    {
        if(a[i]!=a[i-1]) x=i;
        if(a[i]!=a[n])
            ans = ans + fact[x-1]*fact[n-x] %M *fact[n] %M *invf[x-1] %M *invf[n-x+1] %M *a[i] %M;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
const LL M=1000000007;
int n,a[1000010];
LL fact[1000010],invf[1000010];

LL power(LL x,LL e)
{
    if(!e) return 1;
    LL t=power(x,e/2);
    if(e%2) return t*t%M*x%M;
    else return t*t%M;
}

int main()
{
    scanf("%d",&n);
    int i;
    for(fact[0]=1,i=1;i<=n;i++)
        fact[i]=fact[i-1]*i%M;
    for(invf[n]=power(fact[n],M-2),i=n-1;i>=0;i--)
        invf[i]=invf[i+1]*(i+1)%M;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    std::sort(a+1,a+n+1);
    LL ans=0;
    int x;
    for(a[0]=0,i=1;i<=n;i++)
    {
        if(a[i]!=a[i-1]) x=i;
        if(a[i]!=a[n])
            ans = (ans + fact[x-1]*fact[n-x] %M *fact[n] %M *invf[x-1] %M *invf[n-x+1] %M *a[i] %M) %M;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;

signed main()
{
    meow;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; a[i]!=a[n]; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])%MD/fact[i-1-j];
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=(cnt2[i]*a[i])%MD;
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a%MD;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=((fact[i-1]*fact[n-j-1])%MD*binpow(fact[i-1-j],MD-2))%MD;
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=(cnt2[i]*a[i])%MD;
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define fi first
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,a[1000006];
int fact(int n)
{
    int res=1;
    for (int i=2; i<=n; i++)
    {
        res*=i;
        res%=MD;
    }
    return res;
}
signed main()
{
    meow;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int k=fact(n-1);
    int ans=0;
    for (int i=1; i<n && a[i]!=a[n]; i++)
    {
        ans+=(a[i]*k)%MD;
    }
    cout<<ans<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a;
    if (step%2==0)
    {
        int res=binpow(a,step/2);
        return (res*res)%MD;
    }
    else
    {
        return binpow(a,step-1)%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])/binpow(fact[i-1-j],MD-2);
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define fi first
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;

signed main()
{
    meow;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])/fact[i-1-j];
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a;
    if (step%2==0)
    {
        int res=binpow(a,step/2);
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])/binpow(fact[i-1-j],MD-2);
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],cnt1[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a%MD;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    cout<<binpow(3,3)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; a[i]!=a[n]; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
               // cnt1[i]+=(fact[i-1]*fact[n-j-1])%MD/fact[i-1-j];
                cnt2[i]+=((fact[i-1]*fact[n-j-1])%MD*binpow(fact[i-1-j],MD-2))%MD;
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt1[i]<<"and"<<cnt2[i]<<" ";
        ans1+=(cnt2[i]*a[i])%MD;
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=((fact[i-1]*fact[n-j-1])%MD*binpow(fact[i-1-j],MD-2))%MD;
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a;
    if (step%2==0)
    {
        int res=binpow(a,step/2);
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])/binpow(fact[i-1-j],MD-2);
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a;
    if (step%2==0)
    {
        int res=binpow(a,step/2);
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])%MD*binpow(fact[i-1-j],MD-2);
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a;
    if (step%2==0)
    {
        int res=binpow(a,step/2);
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])*binpow(fact[i-1-j],MD-2);
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])%MD*binpow(fact[i-1-j],MD-2);
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],cnt1[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a%MD;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(3,3)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; a[i]!=a[n]; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
               // cnt1[i]+=(fact[i-1]*fact[n-j-1])%MD/fact[i-1-j];
                cnt2[i]+=((fact[i-1]*fact[n-j-1])%MD*binpow(fact[i-1-j],MD-2))%MD;
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt1[i]<<"and"<<cnt2[i]<<" ";
        ans1+=(cnt2[i]*a[i])%MD;
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;

signed main()
{
    meow;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; a[i]!=a[n]; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])%MD/fact[i-1-j];
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;

signed main()
{
    meow;
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; a[i]!=a[n]; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=(fact[i-1]*fact[n-j-1])/fact[i-1-j];
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=cnt2[i]*a[i];
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a%MD;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(2,6)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            for (int j=0; j<i; j++)
            {
                cnt2[i]+=((fact[i-1]*fact[n-j-1])%MD*binpow(fact[i-1-j],MD-1))%MD;
                cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<" ";
        ans1+=(cnt2[i]*a[i])%MD;
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],cnt1[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a%MD;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(3,3)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n+2; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }

    //cout<<"Runtime?"<<endl;
    for (int i=1; a[i]!=a[n]; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            //cout<<"Runtime?"<<endl;
            for (int j=1; j<=i; j++)
            {
                cnt1[i]+=(fact[i-1]*fact[n-j])%MD/fact[i-j];
                //cnt2[i]%=MD;
            }
        }
       // cout<<cnt2[i]<<"_"<<fact[n-i]<<endl;
        //cnt2[i]=fact[n-i];
        cnt2[i]=(((fact[i-1]*fact[n-i])%MD*fact[n])%MD*binpow((fact[i-1]*fact[n-i+1])%MD,MD-2))%MD;
        //cout<<cnt1[i]<<"and"<<cnt2[i]<<" ";
        ans1+=(cnt2[i]*a[i])%MD;
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include "bits/stdc++.h"
#define se second
#define int long long
#define meow ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/// YeAh Red CoMeT ☄☄☄☄☄☄☄ :D
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,ans1,a[1000006],cnt2[1000006],cnt1[1000006],fact[1000006];
vector<int> v;
int binpow(int a, int step)
{
    if (step==1)
        return a%MD;
    if (step%2==0)
    {
        int res=binpow(a,step/2)%MD;
        return (res*res)%MD;
    }
    else
    {
        return (a*binpow(a,step-1))%MD;
    }
}
signed main()
{
    meow;
    cin>>n;
    //cout<<binpow(3,3)<<endl;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    fact[0]=1;
    for (int i=1; i<=n+2; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=MD;
    }

    for (int i=1; a[i]!=a[n]; i++)
    {
        if (a[i]==a[i-1])
            cnt2[i]=cnt2[i-1];
        else
        {
            cnt2[i]=(((fact[i-1]*fact[n-i])%MD*fact[n])%MD*binpow((fact[i-1]*fact[n-i+1])%MD,MD-2))%MD;
        }
        ans1+=(cnt2[i]*a[i])%MD;
        ans1%=MD;

    }
    cout<<ans1<<endl;

}


#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n"
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
int n;
LL pw(LL a,LL b){
	LL t=1;
	while(b){
		if(b&1){
			t=t*a%M;
		}
		a=a*a%M;
		b>>=1;
	}
	return t;
}
int a[N];
int main(){Accel
	cin>>n;
	FOR(i,1,n)
		cin>>a[i];
	LL E=1;
	FOR(i,2,n)E=E*i%M;
	sort(a+1,a+1+n);
	LL ans=0;
	for(int i=1;i<=n;){
		int j=i;
		while(a[i]==a[j])j++;
		if(j<=n)ans=(ans+E*pw(n-i+1,M-2)%M*(j-i)%M*a[i])%M;
		i=j;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n"
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
int n;
LL pw(LL a,LL b){
	LL t=1;
	while(b){
		if(b&1){
			t=t*a%M;
		}
		a=a*a%M;
		b>>=1;
	}
	return t;
}
int a[N];
int main(){Accel
	cin>>n;
	FOR(i,1,n)
		cin>>a[i];
	LL E=1;
	FOR(i,2,n)E=E*i%M;
	sort(a+1,a+1+n);
	LL ans=0;
	FOR(i,1,n){
		int j=i;
		while(a[i]==a[j])j++;
		if(j<=n)ans=(ans+E*pw(n-i+1,M-2)%M*(j-i)%M*a[i])%M;
		i=j;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//size() use int
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//log() = ln() , log(x)/log(y)=log(y)-base-x
//watch out LL
int n;
map<int,int>mp,lc;
LL ans=0;
LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
int main(){Accel
	cin>>n;
	int mx=0;
	LL t=1;
	FOR(i,1,n){
		int x;
		cin>>x;mp[x]++;
		mx=max(mx,x);
		t=t*i%M;
	}
	int c=0;
	for(auto x:mp){
		lc[x.F]=c;
		c+=x.S;
	}
	for(auto x:mp)
		if(x.F!=mx){
			c=n-lc[x.F]	;
			ans=(ans+x.S*(x.F*t%M*pw(c,M-2,M)%M)%M)%M;
		}
	cout<<ans<<endl;

}


#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>
#include <cstring>

using namespace std;

#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;

long long mod_div(long long a, long long b) {
	long long tmp = MOD - 2, c = b, ret = 1;
	while (tmp > 0) {
		if (tmp & 1) {
			ret *= c; ret %= MOD;
		}
		c *= c; c %= MOD; tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 1111111
vector<long long> kaijo(MAX_K);
long long fact(int a) {
	if (kaijo[0] != 1) {
		kaijo[0] = 1;
		for (long long i = 1; i < MAX_K; i++)kaijo[i] = (kaijo[i - 1] * i) % MOD;
	}
	return kaijo[a];
}

long long combination(long long n, long long r) {
	if (n < r || n < 0 || r < 0)
		return 0;
	long long ret = fact(n);
	long long tmp = (fact(r) * fact(n - r)) % MOD;
	return mod_div(ret, tmp);
}

int main() {

	int n; cin >> n;
	vector<ll> v(n);
	int flag = 0;
	REP(i, n) {
		cin >> v[i];
		if (v[i] > 1)flag++;
	}

	sort(ALL(v));
	ll ans = 0;
	if (flag == 1)ans = mod_div(n - 1, n);
	if (flag > 1)ans = 1;
	vector<ll> cou;

	REP(i, n) {
		ll now = i;
		while (i < n - 1 && v[i] == v[i + 1])i++;
		if (v[now] == 1 || i == n - 1)continue;
		ll A = 0, B = 0, C = 0;
		if (now > 0)A = mod_div(now, n) * (i - now + 1) % MOD * mod_div(1, n - now) % MOD;
		if (i - now > 0) B = mod_div(i - now + 1, n) * (i - now) % MOD * mod_div(1, n - now) % MOD;
		if(n - i > 2)C = mod_div(n - i - 1, n) * (i - now + 1) * mod_div(1, n - now - 1) % MOD;
		ll tmp = (A + B + C) % MOD;
		ans = (ans + (tmp * v[now] % MOD)) % MOD;
		//cout << v[now] << " " << A << " " << B << " " << C << endl;
	}

	ans = (ans * fact(n)) % MOD;
	cout << ans << endl;

	return 0;
}