Because range of int in C/C++ is -2147483648 to +2147483647.
So when you add 1, it overflows the max limit of int.
For better understanding, assume the whole range of int puts on a circle in proper order:
2147483647 + 1 == -2147483648
2147483647 + 2 == -2147483647
If you want to overcome this, try to use long long instead of int.