Problem:
Score : 100 points

Problem Statement

How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

Constraints

1 \leq N \leq 10^6

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

4

Sample Output 1

1

There is only one way to choose two distinct integers totaling 4: to choose 1 and 3. (Choosing 3 and 1 is not considered different from this.)

Sample Input 2

999999

Sample Output 2

499999

Solution in Java (OpenJDK 11.0.6) (judge verdict: Runtime Error)



import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			long mod = 998244353;
			int N = scan.nextInt();
			long []D = new long [N];
			Map<Long,Long>map = new TreeMap<Long,Long>();

			for(int i = 0;i<N;i++) {
				D[i] = scan.nextLong();
				if(map.containsKey(D[i]))map.put(D[i], map.get(D[i])+1);
				else map.put(D[i], 1l);
			}


			if(D[0]!=0) {
				System.out.println(0);
				return;
			}

			long goukei = 1;
			long mae = 0;
			for(Long key:map.keySet()) {
				if(key==0) {continue;
				}
				if(key-mae!=1) {
					System.out.println(0);
					System.exit(0);
				}else {
					mae = key;
				}
				
				goukei = (goukei*mod_pow(key,map.get(key),mod))%mod;
				//System.out.println(goukei);
			}

			System.out.println(goukei);



		}


	}

	private static long mod_pow(long x, long n ,long mod) {//Xのn乗を二分累乗法(繰り返し２乗法)で計算modもあり大きくしない
		long res = 1;
		    while(n > 0) {
		    	res = (res*x)%mod;
		        n--;
		    }
		    return res;
	}



}