Defined the sumSlice function.