Let S be the set of {(1,1),(1,−1),(−1,1)}-lattice path which begin at (1,1), do not use the same vertex twice, and never touch either the x-axis or the y-axis. Determine the largest value of n such that every path in S which ends at (n,n) has length at most 50000.