Doubt in DSA learning series

How to do the ADDNTRL question in C++?
Is anything wrong in my code??
My submission is denied all the time.
#include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int N,a;
cin>>N;
a=(N*(N+1))/2;
cout<<a;
return 0;
}

use ‘a’ as long int, in your case a is int type which is out of range

#include
using namespace std;

int main() {
int n, i;
long int sum = 0;

cin>>n;

for (i = 1; i <= n; ++i) {
    sum += i;
}

cout<<sum;
return 0;

}

Series Wrong