#!/usr/bin/env python3 roman_table = [ ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ('IV', 4), ('I', 1), ] def roman_to_int(s): n = 0 for c, e in roman_table: while s.startswith(c): s = s[len(c) :] n += e assert not s return n def int_to_roman(n): s = '' for c, e in roman_table: s += c * (n // e) n %= e assert not n return s _ = int(input()) rs = input().split() acc = sum(map(roman_to_int, rs)) if acc >= 4000: result = 'ERROR' else: result = int_to_roman(acc) print(result)