Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/if-grafikdagi-funksiya

Function from a graph

Easy 1000 ms 64 MB 21%
Share

An integer $x$ is given. Compute the value of the piecewise function:

$$f(x) = \begin{cases} -2 * x - 2, & \text{if } x < -2 \\ x^{2} - 2, & \text{if } -2 \le x \le 2 \\ 2 * x - 2, & \text{if } x > 2 \end{cases}$$

Graph of a piecewise function made of a parabola and straight lines

Input

One integer $x$.

Output

One integer — the value $f(x)$.

Note

$-10^{6} \le x \le 10^{6}$

Examples

Input #1
-3
Output #1
4
Input #2
1
Output #2
-1

Sign in to submit a solution

Signing up is free and takes a minute.