Algorithm to rotate N positions one array