Missax: 354.

Proof. All numbers of {1,…,N+1} appear either in T (if they are present) or are the missing value m . Hence

N a1 a2 … aN (may be split over several lines) The file ends with a line containing 0 , which must be processed. 354. Missax

Proof. By Lemma 2 the value stored in missing after processing the whole test case equals S – T . By Lemma 1 S – T equals the missing element m . Therefore the printed value is exactly m . ∎ Time – each number is read and processed once → O(N) per test case. Memory – only a few 64‑bit variables are kept → O(1) . 6. Reference implementation (C++17) #include <bits/stdc++.h> using namespace std; Therefore the printed value is exactly m

(Typical “find the missing element” problem – often appears on many online judges under the name Missax .) 1. Problem statement You are given an integer N ( 1 ≤ N ≤ 10⁶ ) . Then N distinct integers a₁ , a₂ , … , a_N are supplied. Then N distinct integers a₁

{ 1 , 2 , 3 , … , N+1 } i.e. the list is a permutation of the numbers 1 … N+1 . Your task is to output the missing number.

The input may contain several test cases. Each test case is described as follows