#!/usr/bin/env python3 import functools def compute(ps): m = functools.reduce(lambda x, y: x * y % 9, ps) % 9 return 9 if m == 0 else m def main(): _ = int(input()) ps = [int(p) for p in input().split()] c = compute(ps) print(c) if __name__ == "__main__": main()