codepk, I think that the words have a meaning: if "the max and 2nd max eigen values are equal" then they are not distinct. I assume that $\lambda_1>\lambda_2>\lambda_3\cdots$ and moreover $\lambda_2/\lambda_1$ is near $1$ and $\lambda_3/\lambda_2$ is not near $1$. Of course Beenakker is right, but I think that you can use a simpler method. Firstly, when you solve the iteration $(A-\mu I)x=b$, it is better to choose $\mu>\lambda_1$. Secondly, it is true that the inverse iteration can converge to $\lambda_2$ ; the limit depends on the random choice for the first vector. Yet, in general, the limit is once on two $\lambda_1$ and once on two $\lambda_2$. Thus you do several tests and you keep the maximum of the results. Moreover the eigenvectors associated to $\lambda_1,\lambda_2$ are far from one another because they are orthogonal. Thus, if during an iteration, you move near an already got approximation of an eigenvector, then you can stop the iteration very quickly.
EDIT: This matrix is associated to a PDE. This test is imposed on all beginners. All the eigenvalues of your matrix $A$ are SIMPLE but, when $n$ increases, there is a stack of larger eigenvalues and, then, the problem is difficult. Yet $sup(spectrum(A))$ is near $4$ and $<4$. You can choose $\mu=4$ (cf. above). Do several tests as I wrote above. If you do not find the correct eigenvalue, then follow the advice of Beenakker.