 In one of the sequences (the longer one if unequal length), the element of the middle index is selected.Its position in the other sequence is determined in such a way that this sequence would remain sorted if this element were inserted at this position.Thus, one knows how many other elements from both sequences are smaller and the position of the selected element in the output sequence can be calculated.