And then, we will know that if we move to the next

two suffixes in the stream to the next one after a zero and

the next one after a one, those will both start with letter B.

So the last of the common prefix decreased by, at most,

one, cuzboth suffixes just moved one position to the right, and

we cut away only one position of the longest common prefix.

Of course, these two suffixes are not, probably,

two neighboring suffixes in the suffix array in the general situation.

It might be so that there is some suffix between them.

But because of the property of the LCP array, the longest common prefix

of the smaller suffix with the next suffix in the suffix array will be even bigger or

at least the same as its longest common prefix with the next suffix in the string,

because the next suffix in the string is bigger than the smaller one.

And by the property of LCP array,

the common prefix with the next element is the same or

bigger than the common prefix with some element farther away in the suffix array.

So now, we can move to the next element from the smaller one and

then take the next one to it in the suffix array, and compute their

L speed directly but remembering that the first several characters,

we don't need to compare exactly those, which are in the LCP of the previous pair.

So, this is basically the algorithm.

We compute LCP(A[0] and A[1]) directly and save it's value as variable LCP.

And then on each iteration, first suffix in the pair, which is smaller,

goes to the next in the string, then we find which one is the next

in the suffix array in the order, and we compute their longest common prefix

knowing that we don't need to compare the first lcp- 1 characters.