Let s = s1s2...sk be the string and π(s) = {s1, s2, ..., sk}. |s| denotes the length of the string. pre(s, i) is the length-i prefix of s and suf(s, i) is the length-i suffix of s. Note that the gap at the right end of the self-alignment of s only appears in the segments sk-1 and sk. Denote by se the suffix sk-1sk of s. We can designate that only the last i letters in se are mapped to spaces with score each, for 1 ≤ i ≤ |se|. Now let us consider the remain part pre(se, |se| - i) of se. There are two cases: (1) If i ≥ |sk|, pre(se, |se| - i) is a prefix of sk-1 and is optimally aligned with sk. (2) If i < |sk|, pre(se, |se| - i) contains sk-1 and a prefix of sk. In this case, sk-1 is optimally aligned with sk and the letters in the prefix of sk are scored as μ(x, Δ) each.