I define this equation for 'R' but for first for only one value of 'i' (i refers to the inner sum) and maybe call it 'Ri1'
then I would define this equation as a vector (hope you know what that is) for a vector value of 'i' from '0->I' as given in the attached equation. okay? and redefine the variable as 'RI', finally to get rid of the first summation, use 'sum' command i.e. sum(Ri)
I would follow the same procedure for the second (outer sum). I dont have too much time otherwise I would have tried to do it for you