The detuned string in between likewise has a perfect octave relationship to strings that are two removed.
The E, D and B strings are turned such that they yield clean octaves (and other equal-temperament intervals).
Then so are the A, G and E.
But these two groups are slightly detuned, so that the fifths are clean from the E to A string, D to G, and B to E.