C++编译错误
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function _start': (.text+0x24): undefined reference to
main'
collect2: error: ld returned 1 exit status
#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long n,facn=1,ans;
long long a[1000005],p[1000005],pre[1000005];
long long ksm(long long a,long long b)
{
long long res=1;
while(b)
{
if(b&1)
res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
long long inv(long long x)
{
if(x==0)
return 0;
return ksm(x,mod-2);
}
int mian(){
std::ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
facn=facn*i%mod;
}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)
{
if(a[i]==a[i-1])
{
p[i]=p[i-1];
pre[i]=pre[i-1];
}
else
{
p[i]=i-1;
pre[i]=a[i-1];
}
}
for(int i=1;i<=n;i++)
{
if(a[i]==a[n])
break;
ans=(ans+facn*(inv(n-p[i]))%mod*a[i])%mod;
}
cout<<ans;
return 0;
}