Hide

Problem L
Heiltölusumma

Languages en is

Have you heard of the mathematician Carl Friedrich Gauss? There is a fun story about him from when he was in primary school. One day his teacher was tired of the children’s antics, so he assigned them a hard mathematics problem to keep them busy. The assignment was to add all the numbers from $1$ to $100$. The teacher was quite surprised when Gauss came to the teacher’s desk, only a few moments later, and said he was done. The teacher didn’t believe him of course and asked him to tell him his answer. The teacher hadn’t solved it himself yet, since he didn’t expect anyone to do it this quickly, so he needed a few minutes to verify the answer. And it turned out it was right!

Luckily we have computers these days to do this kind of work for us. Gauss found a way to add the numbers quickly without doing a lot of work, but we aren’t all as smart as him. In this problem we nevertheless want to ask you to solve the same problem: Given an integer $N$, what is the sum of all integers from $1$ to $N$?

Input

A single line containing the integer $N$.

Output

A single line containing the sum of all integers from $1$ to $N$.

Explanation of Sample Inputs

In the first sample $N = 4$. The integers from $1$ to $4$ are $1$, $2$, $3$ and $4$ and their sum is $1+2+3+4=10$.

In the second sample $N = -1$. The integers from $1$ to $-1$ are $-1$, $0$, and $1$ and their sum is $(-1)+0+1=0$.

Scoring

The solution will be tested on differently hard input data and the data is divided into groups as shown in the table below. The solution will then be scored according to how many groups are solved.

Group

Points

Constraints

1

10

$1\leq N\leq 100$

1

20

$1\leq N\leq 10^5$

1

20

$1\leq N\leq 10^9$

1

20

$-100\leq N\leq 100$

1

30

$-10^9\leq N\leq 10^9$

Sample Input 1 Sample Output 1
4
10
Sample Input 2 Sample Output 2
-1
0
Sample Input 3 Sample Output 3
100
5050