等差数列an的前n项和为Sn,若a1=2,s3=12求an