#include using namespace std; #include typedef boost::multiprecision::cpp_int mp; int main(){ int N,K; cin>>N>>K; vector A(N); mp s=0; for(int i=0;i>A[i]; s+=A[i]; } mp ans=0; mp temp=1; for(int i=N-1;i>=0;i--){ ans=(ans+temp*A[i])%s; temp=(temp*K)%s; } cout<