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

using namespace std;
using namespace boost::multiprecision;

// 各桁の和を求める関数(ループ回数削減のために高速化)
inline int digit_sum(const string &x) {
    int res = 0;
    for (char c : x) {
        res += c - '0';
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    cpp_int y = 1;
    for (int i = 0; i < n; ++i) {
        long long k;
        cin >> k;
        y *= k;
    }
    
    string y_str = y.str();
    while (y_str.length() > 1) {
        y_str = to_string(digit_sum(y_str));
    }
    
    cout << y_str << '\n';
    return 0;
}