If n arithmetic means are inserted between 1 and 31 such that the ratio of the first mean and nth mean is 3 : 29, then the value of n is