import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); HashSet used = new HashSet<>(); int count = 0; for (int i = 0; i < n; i++) { int x = Integer.parseInt(br.readLine()); for (int j = 1; j < x; j++) { if (!used.contains(j)) { count++; } } used.add(x); } System.out.println(count); } }