If the second, third and fourth terms in the expansion of (x+a)n are 240,720 and 1080 respectively, then the value of n is