sum of l*i with i from 1 to k