等差数列{an}的前n项和为Sn,已知S6=36,Sn=324,S(n-6)=144(n>6),则n为多少?