An algorithm for separating multilevel random telegraph signal from 1/f noise