import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { public static class Data implements Comparable { int data, index; public Data(int data, int index){ this.data = data; this.index = index; } @Override public int compareTo(Data arg0){ return Integer.compare(arg0.data, this.data); } } public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); PriorityQueue queue = new PriorityQueue(); for(int i = 0; i < N; i++){ queue.add(new Data(sc.nextInt(), i)); } TreeSet indexes = new TreeSet(); while(!queue.isEmpty()){ //System.out.println(queue); final Data data = queue.poll(); if(indexes.lower(data.index) != null){ System.out.println(queue.size() + 1); return; }else{ indexes.add(data.index); } } System.out.println(0); } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public void close() throws IOException { br.close(); } } }