{"raw_statement":[{"iden":"statement","content":"Gaby is a little baby who loves playing with numbers. Recently she has learned how to add 2 numbers using the standard addition algorithm which we summarize in 3 steps:\n\nit means when adding two numbers we will get something like this:\n\nUnfortunately as Gaby is too young she doesn't know what the third step means so she just omitted this step using her own standard algorithm (Gaby's addition algorithm). When adding two numbers without carrying when necessary she gets something like the following:\n\nGaby loves playing with numbers so she wants to practice the algorithm she has just learned (in the way she learned it) with a list of numbers adding every possible pair looking for the pair which generates the largest value and the smallest one. \n\nShe needs to check if she is doing it correctly so she asks for your help to find the largest and the smallest value generated from the list of numbers using Gaby's addition algorithm.\n\nThe input starts with an integer n (2 ≤ n ≤ 106) indicating the number of integers Gaby will be playing with. The next line contains n numbers ni (0 ≤ ni ≤ 1018) separated by a single space.\n\nOutput the smallest and the largest number you can get from adding two numbers from the list using Gaby's addition algorithm.\n\nIn the first sample input this is how you get the minimum and the maximum value\n\n"},{"iden":"input","content":"The input starts with an integer n (2 ≤ n ≤ 106) indicating the number of integers Gaby will be playing with. The next line contains n numbers ni (0 ≤ ni ≤ 1018) separated by a single space."},{"iden":"output","content":"Output the smallest and the largest number you can get from adding two numbers from the list using Gaby's addition algorithm."},{"iden":"examples","content":"Input617 5 11 0 42 99Output0 99Input7506823119072235413 991096248449924896 204242310783332529 778958050378192979 384042493592684633 942496553147499866 410043616343857825Output52990443860776502 972190360051424498"},{"iden":"note","content":"In the first sample input this is how you get the minimum and the maximum value  "}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of integers, with $ 2 \\leq n \\leq 10^6 $.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of integers, where $ 0 \\leq a_i \\leq 10^{18} $ for all $ i $.  \n\nDefine **Gaby's addition** $ \\oplus $: for two non-negative integers $ x, y $,  \n$$\nx \\oplus y = \\sum_{k=0}^{\\infty} \\left( (d_k(x) + d_k(y)) \\mod 10 \\right) \\cdot 10^k\n$$  \nwhere $ d_k(z) $ is the $ k $-th digit (from right, 0-indexed) of $ z $, and $ d_k(z) = 0 $ if $ z $ has no $ k $-th digit.\n\n**Constraints**  \n1. $ 2 \\leq n \\leq 10^6 $  \n2. $ 0 \\leq a_i \\leq 10^{18} $ for all $ i \\in \\{1, \\dots, n\\} $\n\n**Objective**  \nFind:  \n$$\n\\min_{1 \\leq i < j \\leq n} (a_i \\oplus a_j), \\quad \\max_{1 \\leq i < j \\leq n} (a_i \\oplus a_j)\n$$","simple_statement":"Given a list of numbers, find the smallest and largest result when adding any two numbers using Gaby’s addition algorithm — which is regular addition without carry.","has_page_source":false}