add length to r and array