If the sum of first 7 terms of an AP is 49 and that of 17 term is 289 find the sum of first n terms.