#include <bits/stdc++.h>
using namespace std;

#define int long long

const long double PI = 3.14159265359;

void solve()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    for (auto &val : arr)
        cin >> val;
    if (count(arr.begin(), arr.end(), 9) == 0)
        cout << -1 << '\n';
    else
        cout << *min_element(arr.begin(), arr.end()) << '\n';
}

signed main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}