Problem:
Score : 100 points

Problem Statement

You are given a positive integer N.
Find the minimum positive integer divisible by both 2 and N.

Constraints

1 \leq N \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Print the minimum positive integer divisible by both 2 and N.

Sample Input 1

3

Sample Output 1

6

6 is divisible by both 2 and 3.
Also, there is no positive integer less than 6 that is divisible by both 2 and 3.
Thus, the answer is 6.

Sample Input 2

10

Sample Output 2

10

Sample Input 3

999999999

Sample Output 3

1999999998

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)){

            int n = sc.nextInt();
			int[] A = new int[n];
			int[] B = new int[n];

			for (int i = 0; i < n; i++) {
                A[i] = sc.nextInt();
            }
			// 中央値用取得の値コレクション
			for (int i = 0; i < n; i++) {
				B[i] = A[i] - (i+1);
			}
			// 中央値の取得
			int median = getMedian(B);

			// 悲しみを取得
			int sadness = getSadness(A, median);

            System.out.println(sadness);
		}
    }

    /**
     * すぬけ君の悲しみ.
     *
     * @param R 長さNの整数列A
     * @param b すぬけ君が選ぶ数値
     */
    public static int getSadness(int[] A, int b) {
        int result = 0;
        for (int i = 0; i < A.length; i++) {
            result += abs(A[i] - (b + i+1));
        }
        return result;
    }

    // 絶対値を返す
    public static int abs(int num) {
        if (num < 0) {
            num *= -1;
        }
        return num;
    }

    // additional : 中央値を返す
    public static int getMedian(int[] B){
    	// データ数
    	int n = B.length;
    	Arrays.sort(B);

    	// 中央値を求める
    	int result = 0;
    	if (n % 2 == 1) {
    		// データ数が奇数
    		result = B[n/2];
    	} else {
    		// データ数が偶数
    		result = (B[n/2-1] + B[n/2])/2;
    	}
    	return result;
    }
}