Tune N according to the box lengths.