#996. 田忌赛马

田忌赛马

说明

你要和田忌赛马。你们各自有 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 匹马,并且要进行 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 轮比赛,每轮比赛,你们都要各派出一匹马决出胜负。

你的马匹的速度分别为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi>�</mi><mn>2</mn></msub><mo separator="true">,</mo><mo>⋯</mo><mtext>,</mtext><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>u1,u2,un,田忌的马匹的速度分别为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi>�</mi><mn>2</mn></msub><mo separator="true">,</mo><mo>⋯</mo><mtext> </mtext><mo separator="true">,</mo><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>v1,v2,,vn。田忌会按顺序派出他的马匹,请问你要如何排兵布阵,才能赢得最多轮次的比赛?巧合的是,你和田忌的所有马匹的速度两两不同,因此不可能出现平局。

输入格式

第一行一个整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N。保证 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>5</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mn>4</mn></msup></mrow></semantics></math>1N5×104

接下来一行 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 个用空格隔开的整数,依次为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi>�</mi><mn>2</mn></msub><mo separator="true">,</mo><mo>⋯</mo><mtext> </mtext><mo separator="true">,</mo><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>u1,u2,,un,表示你的马匹们的速度。保证 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><msub><mi>�</mi><mi>�</mi></msub><mo>≤</mo><mn>2</mn><mi>�</mi></mrow></semantics></math>1ui2N

接下来一行 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 个用空格隔开的整数,依次为 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi>�</mi><mn>2</mn></msub><mo separator="true">,</mo><mo>⋯</mo><mtext> </mtext><mo separator="true">,</mo><msub><mi>�</mi><mi>�</mi></msub></mrow></semantics></math>v1,v2,,vn,表示田忌的马匹们的速度。保证 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><msub><mi>�</mi><mi>�</mi></msub><mo>≤</mo><mn>2</mn><mi>�</mi></mrow></semantics></math>1vi2N

输出格式

输出一行,表示你最多能获胜几轮。

样例

3
1 3 5
2 4 6
2