n,m,k=gets.split(" ").map{|e| e.to_i} xs=gets.chomp.split(" ") op=xs.shift s1=xs.map{|e| e.to_i}.sum ans=0 if op=="+" then n.times{ ans+=s1+gets.to_i*m } else n.times{ ans+=gets.to_i*s1 } end puts ans%k