#include #include #include #include #define f(i,beg,end) for(int i=beg; i<=end; i++) #define mod 1000000007 typedef long long ll; using namespace std; int n; pair a1[1000], ans[1000]; ll komb[1001][1001]; void redirect() { //freopen("test.txt","r",stdin); freopen("median.in","r",stdin); freopen("median.out","w",stdout); } bool cmp1(pair p1, pair p2) { return p1.first p1, pair p2) { return p1.second> n; f(i,0,n-1) { cin >> a1[i].first; a1[i].second = i; } sort(a1,a1+n,cmp1); } ll fastPow(int x, int power) { if (power==0) return 1LL; if (power==1) return (x%mod); ll ret = x; if (power%2==0) { ret = fastPow(x,power/2); return (ret*ret)%mod; } else return (ret * fastPow(x,power-1)) % mod; } inline ll comb(int k, int n) { ll a = 1LL, b=1LL; if (k>n) return 0; ll i, j; for(i=1, j=n; i<=k; i++, j--) { a*=j; b*=i; if (a>=mod) a%=mod; if (b>=mod) b%=mod; } ll reverseB = fastPow(b,mod-2); return (a*reverseB) % mod; } ll calc(int ind, ll len) { //cout << " IND " << ind << " LEN " << len << endl; int pos = (len+2)/2, before = pos-1, after = len - pos; //ll ret = 0LL, a = comb(before, ind-1), b = comb(after, n-ind); ll ret = 0LL, a = komb[before][ind-1], b = komb[after][n-ind]; ret = (a*b) % mod; //cout << "comb " << before << " " << ind-1 << ": " << a << endl << " comb " << after <<" " << n-ind-1 << " = " << b << endl << endl; //cout << a1[ind].first << " " << len << " = " << ret << endl; //cout << ret << endl; return ret; } void solve() { f(i,0,n) f(j,0,n) komb[i][j] = comb(i,j); f(i,0,n-1) { ans[i].first=0; ans[i].second = a1[i].second; for(ll len=1; len<=n; len++) ans[i].first += calc(i+1,len); } // f(i,0,n-1) // cout << a1[i].first << " " << ans[i].first << endl; sort(ans,ans+n,cmp2); cout << ans[0].first; f(i,1,n-1) cout << " " << ans[i].first; cout << endl; } int main() { redirect(); init(); solve(); return 0; }