Point $$B$$ is in the exterior of the regular $$n$$-sided polygon $$A_1A_2\cdots A_n$$, and $$A_1A_2B$$ is an equilateral triangle. What is the largest value of $$n$$ for which $$A_1$$, $$A_n$$, and $$B$$ are consecutive vertices of a regular polygon?

(第十五届AIME1997 第6题)