fixed n

Fixed unexpected output caused by overflow from using n as an int.
Changed n to a long long and expected output is achieved.