import java.io.BufferedReader ;
import java.io.IOException ;
import java.io.InputStreamReader ;
import java.io.StreamTokenizer ;
import java.util.ArrayList ;
import java.util.Collections ;
import java.util.Iterator ;
import java.util.TreeSet ;
import java.lang.Integer ;
public class multithreading_kp_java {
static int nextInt( ) {
try {
st.nextToken ( ) ;
return ( int ) st.nval ;
return 0 ;
}
}
public static void main
( String [ ] args
) { int n = nextInt( ) ;
ArrayList< Integer> l= new ArrayList< Integer> ( ) ;
for ( int i = 0 ; i < n; i++ ) {
l.add ( nextInt( ) ) ;
}
int ans = n - 1 ;
for ( int i = n - 1 ; i > 0 ; i-- ) {
if ( l.get ( i) < l.get ( i - 1 ) ) {
break ;
}
ans--;
}
}
}
CmltcG9ydCBqYXZhLmlvLkJ1ZmZlcmVkUmVhZGVyOwppbXBvcnQgamF2YS5pby5JT0V4Y2VwdGlvbjsKaW1wb3J0IGphdmEuaW8uSW5wdXRTdHJlYW1SZWFkZXI7CmltcG9ydCBqYXZhLmlvLlN0cmVhbVRva2VuaXplcjsKaW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7CmltcG9ydCBqYXZhLnV0aWwuQ29sbGVjdGlvbnM7CmltcG9ydCBqYXZhLnV0aWwuSXRlcmF0b3I7CmltcG9ydCBqYXZhLnV0aWwuVHJlZVNldDsKaW1wb3J0IGphdmEubGFuZy5JbnRlZ2VyOwoKcHVibGljIGNsYXNzIG11bHRpdGhyZWFkaW5nX2twX2phdmEgewoKICAgIHN0YXRpYyBTdHJlYW1Ub2tlbml6ZXIgc3QgPSBuZXcgU3RyZWFtVG9rZW5pemVyKG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgSW5wdXRTdHJlYW1SZWFkZXIoU3lzdGVtLmluKSkpOwoKICAgIHN0YXRpYyBpbnQgbmV4dEludCgpIHsKICAgICAgICB0cnkgewogICAgICAgICAgICBzdC5uZXh0VG9rZW4oKTsKICAgICAgICAgICAgcmV0dXJuIChpbnQpIHN0Lm52YWw7CiAgICAgICAgfSBjY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