I am not able to understand why I am getting the wrong output error. Any help will be appreciated.
long long int b;
long int a = (n*(n-1))/2;
Please post your code as an actual code, its hard to understand what you have posted.
You need to define (declare,assign and read) both variables n and a as
long long int to avoid integer overflow.
Check your same code accepted with this modifications here.
P.S.: Always format your code correctly or provide link when asking for help.
I will keep it in mind next time to post the code correctly.