#include <iostream>
#include <vector>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

// 各桁の和を求める関数
int digit_sum(const string &x) {
    int res = 0;
    for (char c : x) {
        res += c - '0';
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    
    cpp_int y = 1;
    for (int k : x) {
        y *= k;
    }
    
    string y_str = y.str();
    while (y_str.length() != 1) {
        y_str = to_string(digit_sum(y_str));
    }
    
    cout << y_str << endl;
    return 0;
}