Masking of 2 bits

What does this syntax mean? can someone explain why is there a -1?
in the line 15.

int mask = (1<<i) -1;

1<< i is used to find 2^i
in 2^i msb will be 1 and other bits will be all 0
if we want all 1’s then subtract 1 from this

ex
1<<5 ==> 100000
(1<<5)-1 ==> 11111