If the sum of three consecutive terms of an A.P. is 45 and the sum of their squares is 707, then what is the difference between the smallest and the greatest term?