I changed the generate_array
It still have a problem wen R = 100000000 and N = 100000
It work well if we don't go that big
test