The given series is an, then we can write as
an=5+8+14+23+............+anan=5+8+14+23+......+an−1+an
Subtracting above equations, we get
0=5+3+6+9+....+(an−an−1)−an
⇒an=5+[2(n−1)(2×3+(n−1−1)3)]
⇒an=5+2(n−1)(3n)
⇒an=21(3n2−3n+10)
So,
⇒a40=21(3×402−3×40+10)
⇒a40=21(4800−120+10)
⇒a40=2345
⇒S30=∑n=130an
⇒S30=21(3∑n=130(n2)−3∑n=130(n)+∑n=13010)
=21(63(30)(31)(61)−23(30)(31)+10×30)
⇒S30=13635
⇒S30−a40=13635−2345=11290
Therefore, the required value is 11290.