Rs = {"I": 1, "V": 5, "X":10, "L": 50, "C": 100, "D": 500, "M": 1000} def RtoInt(Ri): #Ri: str key = list(Ri) value = [Rs[i] for i in key] for k in range(len(value) - 1): if value[k] < value[k + 1]: value[k] = -1 * value[k] return sum(value) def InttoR(n): strn = str(n) res = "" for i in range(len(strn)): numi = int(strn[- i - 1]) if numi == 4: if i == 0: res = "IV" + res elif i == 1: res = "XL" + res elif i == 2: res = "CD" + res elif numi == 9: if i == 0: res = "IX" + res elif i == 1: res = "XC" + res elif i == 2: res = "CM" + res elif numi > 4: if i == 0: res = "V" + "I" * (numi-5) + res elif i == 1: res = "L" + "X" * (numi-5) + res elif i == 2: res = "D" + "C" * (numi-5) + res elif numi < 4: if i == 0: res = "I" * numi + res elif i == 1: res = "X" * numi + res elif i == 2: res = "C" * numi + res elif i == 3: res = "M" * numi + res return res N = int(input()) R = list(input().split(" ")) #N = 5 #R = list("IV XXI CCCXL III MMCMVI".split()) Rint = list(map(RtoInt, R)) sumR = sum(Rint) if sumR > 3999: print("ERROR") else: print(InttoR(sumR))