using static System.Console;
using static System.Convert;
using System.Linq;
public class Program {
public static void Main() {
WriteLine("O maior numero é " + Teste(4242));
WriteLine("O maior numero é " + Teste(123));
WriteLine("O maior numero é " + Teste(100009));
WriteLine("O maior numero é " + Teste(10000000));
}
public static int Teste(int number) => number >= 10000000 ? -1 : ToInt32(new string(number.ToString().OrderByDescending(x => x).ToArray()));
}
//https://pt.stackoverflow.com/q/110892/101
dXNpbmcgc3RhdGljIFN5c3RlbS5Db25zb2xlOwp1c2luZyBzdGF0aWMgU3lzdGVtLkNvbnZlcnQ7CnVzaW5nIFN5c3RlbS5MaW5xOwoJCQkJCQpwdWJsaWMgY2xhc3MgUHJvZ3JhbSB7CglwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpIHsKCQlXcml0ZUxpbmUoIk8gbWFpb3IgbnVtZXJvIMOpICIgKyBUZXN0ZSg0MjQyKSk7CgkJV3JpdGVMaW5lKCJPIG1haW9yIG51bWVybyDDqSAiICsgVGVzdGUoMTIzKSk7CgkJV3JpdGVMaW5lKCJPIG1haW9yIG51bWVybyDDqSAiICsgVGVzdGUoMTAwMDA5KSk7CgkJV3JpdGVMaW5lKCJPIG1haW9yIG51bWVybyDDqSAiICsgVGVzdGUoMTAwMDAwMDApKTsKCX0KCXB1YmxpYyBzdGF0aWMgaW50IFRlc3RlKGludCBudW1iZXIpID0+IG51bWJlciA+PSAxMDAwMDAwMCA/IC0xIDogVG9JbnQzMihuZXcgc3RyaW5nKG51bWJlci5Ub1N0cmluZygpLk9yZGVyQnlEZXNjZW5kaW5nKHggPT4geCkuVG9BcnJheSgpKSk7Cn0KCi8vaHR0cHM6Ly9wdC5zdGFja292ZXJmbG93LmNvbS9xLzExMDg5Mi8xMDE=