{"raw_statement":[{"iden":"problem statement","content":"$10^9$ contestants, numbered $1$ to $10^9$, will compete in a competition. There will be two contests in this competition.\nThe organizer prepared $N$ problems, numbered $1$ to $N$, to use in these contests. When Problem $i$ is presented in a contest, it will be solved by all contestants from Contestant $L_i$ to Contestant $R_i$ (inclusive), and will not be solved by any other contestants.\nThe organizer will use these $N$ problems in the two contests. Each problem must be used in exactly one of the contests, and each contest must have at least one problem.\nThe _joyfulness_ of each contest is the number of contestants who will solve all the problems in the contest. Find the maximum possible total joyfulness of the two contests."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 10^5$\n*   $1 \\leq L_i \\leq R_i \\leq 10^9$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$L_1$ $R_1$\n$L_2$ $R_2$\n$\\vdots$\n$L_N$ $R_N$"},{"iden":"sample input 1","content":"4\n4 7\n1 4\n5 8\n2 5"},{"iden":"sample output 1","content":"6\n\nThe optimal choice is:\n\n*   Use Problem $1$ and $3$ in the first contest. Contestant $5$, $6$, and $7$ will solve both of them, so the joyfulness of this contest is $3$.\n*   Use Problem $2$ and $4$ in the second contest. Contestant $2$, $3$, and $4$ will solve both of them, so the joyfulness of this contest is $3$.\n*   The total joyfulness of these two contests is $6$. We cannot make the total joyfulness greater than $6$."},{"iden":"sample input 2","content":"4\n1 20\n2 19\n3 18\n4 17"},{"iden":"sample output 2","content":"34"},{"iden":"sample input 3","content":"10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526"},{"iden":"sample output 3","content":"540049931"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}