// 4 3 2 1
//
// ( = +1
// ) = -1
// >= 0 every time
// == 0 at the end

#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
 
#define DEBUG(X) { auto _X = (X); cerr << "L" << __LINE__ << ": " << #X << " = " << (_X) << endl; }
#define PR(A, n) { cerr << "L" << __LINE__ << ": " << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << "L" << __LINE__ << ": " << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }
 
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define TWO(x) (1LL<<(x))
inline int gcd(int a, int b) {int r; while (b) {r = a % b; a = b; b = r;} return a;}

// for 64-bit, use mt19937_64
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// use shuffle instead of random_shuffle
#define random_shuffle askcjaljc

const int MN = 400111;
int a[MN];
pair<int,int> b[MN];

int32_t main() {
    ios::sync_with_stdio(0);
    int n; cin >> n;
    n *= 2;
    FOR(i,1,n) {
        cin >> a[i];
        b[i] = {a[i], i};
    }
    sort(b+1, b+n+1);
    FOR(i,1,n/2) a[b[i].second] = 0;
    FOR(i,n/2+1,n) a[b[i].second] = 1;

    int sum = 0;
    int open = -1;
    FOR(i,1,n) {
        if (sum == 0) {
            open = a[i];
            sum++;
            cout << '(';
            continue;
        }

        if (a[i] == open) {
            cout << '(';
            sum++;
            continue;
        }

        cout << ')';
        --sum;
    }
    cout << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

bool solve(string &S) {
    if (S.size() <= 5) {
        sort(S.begin(), S.end());
        do {
            int val = 0;
            for (auto c : S) val = val * 10 + (int)(c-'0');
            if (val % 8 == 0) return true;
        } while (next_permutation(S.begin(), S.end()));
        return false;
    }
    vector<int> num(10, 0);
    for (const auto c : S) num[c-'0']++;
    for (int i = 0; i < 1000; i += 8) {
        vector<int> simo(10, 0);
        int i2 = i;
        for (int iter = 0; iter < 3; ++iter) {
            simo[i2 % 10]++;
            i2 /= 10;
        }
        if (simo[0]) continue;
        bool ok = true;
        for (int v = 0; v < 10; ++v) if (simo[v] > num[v]) ok = false;
        if (ok) return true;
    }
    return false;
}

int main() {
    string S;
    while (cin >> S) {
        if (solve(S)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}