Given an=∫−1n(1+2x+3x2+….+nxn−1)dx
=[x+22x2+32x3+……+n2xn]−1n
i.e. an=12n+1+22n2−1+32n3+1+42n4−1+…+n2nn+(−1)n+1
Here a1=2,a2=12+1+222−1=29,
a3=4+2+928=9100,
a4=5+415+965+16255>31.
∵an∈(2,30), so the required set is 2,3.
∴ sum of all elements =5.