def roman_to_int(s): roman = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000} total = 0 prev_value = 0 for c in reversed(s): current_value = roman[c] if current_value < prev_value: total -= current_value else: total += current_value prev_value = current_value return total def int_to_roman(num): val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syms = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ] res = '' i = 0 while num > 0: while num >= val[i]: res += syms[i] num -= val[i] i += 1 return res n = int(input()) romans = input().split() sum_total = sum(roman_to_int(r) for r in romans) if sum_total > 3999: print("ERROR") else: print(int_to_roman(sum_total))