import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); sa = br.readLine().split(" "); int[] a = new int[n]; Set set = new HashSet<>(); for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); if (a[i] <= n) { set.add(a[i]); } } br.close(); System.out.println(a[n - 1] - n); } }