package yukicoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; public class No518Another { static Map n2r = new HashMap() { { put(1, "I"); put(2, "II"); put(3, "III"); put(4, "IV"); put(5, "V"); put(6, "VI"); put(7, "VII"); put(8, "VIII"); put(9, "IX"); put(10, "X"); put(11, "XI"); put(13, "XIII"); put(17, "XVII"); put(20, "XX"); put(21, "XXI"); put(30, "XXX"); put(33, "XXXIII"); put(40, "XL"); put(46, "XLVI"); put(50, "L"); put(51, "LI"); put(60, "LX"); put(66, "LXVI"); put(69, "LXIX"); put(71, "LXXI"); put(80, "LXXX"); put(90, "XC"); put(94, "XCIV"); put(100, "C"); put(101, "CI"); put(128, "CXXVIII"); put(200, "CC"); put(201, "CCI"); put(222, "CCXXII"); put(256, "CCLVI"); put(300, "CCC"); put(316, "CCCXVI"); put(340, "CCCXL"); put(400, "CD"); put(425, "CDXXV"); put(433, "CDXXXIII"); put(444, "CDXLIV"); put(490, "CDXC"); put(500, "D"); put(501, "DI"); put(506, "DVI"); put(579, "DLXXIX"); put(600, "DC"); put(700, "DCC"); put(743, "DCCXLIII"); put(800, "DCCC"); put(900, "CM"); put(999, "CMXCIX"); put(1000, "M"); put(1001, "MI"); put(1006, "MVI"); put(1111, "MCXI"); put(1132, "MCXXXII"); put(1258, "MCCLVIII"); put(1300, "MCCC"); put(1674, "MDCLXXIV"); put(1844, "MDCCCXLIV"); put(2000, "MM"); put(2906, "MMCMVI"); put(3001, "MMMI"); put(3998, "MMMCMXCVIII"); } }; static Map r2n = new HashMap() { { put("I", 1); put("II", 2); put("III", 3); put("IV", 4); put("V", 5); put("VI", 6); put("VII", 7); put("VIII", 8); put("IX", 9); put("X", 10); put("XI", 11); put("XIII", 13); put("XVII", 17); put("XX", 20); put("XXI", 21); put("XXX", 30); put("XXXIII", 33); put("XL", 40); put("XLVI", 46); put("L", 50); put("LI", 51); put("LX", 60); put("LXVI", 66); put("LXIX", 69); put("LXXI", 71); put("LXXX", 80); put("XC", 90); put("XCIV", 94); put("C", 100); put("CI", 101); put("CXXVIII", 128); put("CC", 200); put("CCI", 201); put("CCXXII", 222); put("CCLVI", 256); put("CCC", 300); put("CCCXVI", 316); put("CCCXL", 340); put("CD", 400); put("CDXXV", 425); put("CDXXXIII", 433); put("CDXLIV", 444); put("CDXC", 490); put("D", 500); put("DI", 501); put("DVI", 506); put("DLXXIX", 579); put("DC", 600); put("DCC", 700); put("DCCXLIII", 743); put("DCCC", 800); put("CM", 900); put("CMXCIX", 999); put("M", 1000); put("MI", 1001); put("MVI", 1006); put("MCXI", 1111); put("MCXXXII", 1132); put("MCCLVIII", 1258); put("MCCC", 1300); put("MDCLXXIV", 1674); put("MDCCCXLIV", 1844); put("MM", 2000); put("MMCMVI", 2906); put("MMMI", 3001); put("MMMCMXCVIII", 3998); } }; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in.readLine(); String romanStr = in.readLine(); List romans = Arrays.asList(romanStr.split(" ")); int value = 0; for (String roman : romans) { value += r2n.get(roman); } System.out.println(n2r.get(value)); } }