0 length- 1(epsilon)
1 length- n(we can chhioose any bit of string)
2lengh- n-1 (on the rhs we have n-1 options as we cant take the first letter as it will become 1length substrng and lhs is fixed as substrinng is contiguos)
3 length substring- n-2(same way rhs last place has n-2 options as first 2 places cant take this place)
simiarly n length substring- 1
so 1+2+3+............n +1= n(n+1)/2 +1