an array call beautiful element array equalyou transform array follow step number time Choose indice j 1 leq ij leq n integer x 1 leq x leq a_i let source index j sink index Decrease ith element x increase jth element x the result value ith jth index a_ix a_jx respectively the cost operation x cdot ji now ith index long sink jth index long source the total cost transformation sum cost step 3for example array 0 2 3 3 transform beautiful array 2 2 2 2 total cost 1 cdot 13 1 cdot 14 5an array call balanced transform beautiful array cost transformation uniquely define in word minimum cost transformation beautiful array equal maximum costYou give array a_1 a_2 ldot a_n length n consist nonnegative integer your task find number balance array permutation give array two array consider different element position differ since answer large output modulo 109 7