Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	ps := make([]int, n)
	for i := range ps {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())
		ps[i] = p
	}

	mp := make([]int, n+1)
	ans := make([]byte, 0)
	var pp, max int
	for _, p := range ps {
		mp[p] = 1
		if p < pp {
			if mp[p+1] != 1 {
				fmt.Println(":(")
				return
			}
			ans = append(ans, ')')
		} else {
			for i := max; i < p-1; i++ {
				ans = append(ans, '(')
			}
			ans = append(ans, '(')
			ans = append(ans, ')')
		}
		if p > max {
			max = p
		}
		pp = p
	}
	fmt.Println(string(ans))
}

C++: // includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
#include <array>
#include <deque>
#include <list>
#include <ostream>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
template < int n, class... T >
typename enable_if< (n >= sizeof...(T)) >::type __output_tuple(ostream &,
    tuple< T... > const &) {}
template < int n, class... T >
typename enable_if< (n < sizeof...(T)) >::type __output_tuple(ostream &os,
    tuple< T... > const &t) {
  os << (n == 0 ? "" : ", ") << get< n >(t);
  __output_tuple< n + 1 >(os, t);
}
template < class... T >
ostream &operator<<(ostream &os, tuple< T... > const &t) {
  os << "(";
  __output_tuple< 0 >(os, t);
  os << ")";
  return os;
}
template < class T, class U >
ostream &operator<<(ostream &os, pair< T, U > const &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template < class T >
ostream &operator<<(ostream &os, const stack< T > &a) {
  os << "{";
  for(auto tmp = a; tmp.size(); tmp.pop())
    os << (a.size() == tmp.size() ? "" : ", ") << tmp.top();
  os << "}";
  return os;
}
template < class T, class Container, class Compare >
ostream &operator<<(ostream &os, priority_queue< T, Container, Compare > a) {
  os << "{ (top) ";
  while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
template < class T, class Container >
ostream &operator<<(ostream &os, queue< T, Container > a) {
  os << "{ ";
  while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
#ifdef DEBUG
#if !defined(DEBUG_OUT)
#define DEBUG_OUT cerr
#endif
#define dump(...)                                                                \
  [&]() {                                                                        \
    auto __debug_tap = make_tuple(__VA_ARGS__);                                  \
    DEBUG_OUT << "[" << __LINE__ << "] " << #__VA_ARGS__ << " = " << __debug_tap \
    << endl;                                                           \
  }()
template < class T >
inline void dump2D(T &d, size_t sizey, size_t sizex) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << "\t";
    for(size_t j = 0; j < sizex; j++)
      DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t");
    DEBUG_OUT << endl;
  }
}
template < class T >
inline void dump1D(T &d, size_t sizey) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << d[i] << (i + 1 == sizey ? "" : " ");
  }
  DEBUG_OUT << endl;
}
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type,
         class = typename enable_if< !is_same< T, string >::value >::type >
         ostream &operator<<(ostream &os, const T &a) {
           os << "{";
           for(auto ite = begin(a); ite != end(a); ++ite)
             os << (ite == begin(a) ? "" : ", ") << *ite;
           os << "}";
           return os;
         }
#else
#define dump(...) (42)
#define dump2D(...) (42)
#define dump1D(...) (42)
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type,
         class = typename enable_if< !is_same< T, string >::value >::type >
         ostream &operator<<(ostream &os, const T &a) {
           for(auto ite = begin(a); ite != end(a); ++ite)
             os << (ite == begin(a) ? "" : " ") << *ite;
           return os;
         }
#endif
// }}}


int a[112345];

void NO() {
  cout << ":(" << endl;
  exit(0);
}

deque<char>* mrg(deque<char>* a, deque<char>* b) {
  if(!b) return a;
  assert(a);
  if(a->size() > b->size()) {
    for(auto e: *b) {
      a->push_back(e);
    }
    return a;
  } else {
    for(int i = (int) a->size() - 1; i >= 0; i--) {
      b->push_front((*a)[i]);
    }
    return b;
  }
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  // vector<pair<int, int>> v;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    // v.emplace_back(i, a[i]);
  }
  vector<tuple<int, int, deque<char>*>> u;
  const int inf = 1e9;
  u.emplace_back(inf, -1, new deque<char>);
  for(int i = 0; i < n; i++) {
    int id = a[i];
    // tie(ignore, id) = v[i];
    deque<char>* carry = new deque<char>;
    int las = id;
    while(u.size() && get<0>(u.back()) > id) {
      auto d = u.back();
      las = max(las, get<1>(d));
      carry = mrg(get<2>(d), carry);
      u.pop_back();
    }
    if(u.size() && get<1>(u.back()) >= id) NO();
    carry->push_back(')');
    carry->push_front('(');
    u.emplace_back(id, las, carry);
  }

  string ans;
  for(auto e : u) {
    for(auto c : *get<2>(e)) {
      ans += c;
    }
  }
  
  cout << ans << endl;
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/












int N, P[101010], A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> P[i];

    string ans = "";
    int cnt = 0;
    rep(i, 0, N) {
        while (cnt < P[i]) {
            ans += "(";
            cnt++;
        }
        ans += ")";
    }

    stack<int> stk;
    int st = 1;
    int idx = 0;
    rep(i, 0, N * 2) {
        if (ans[i] == '(') {
            stk.push(st);
            st++;
        }
        else {
            if (stk.size() == 0) {
                printf(":(\n");
                return;
            }

            A[idx] = stk.top();
            stk.pop();
            idx++;
        }
    }

    rep(i, 0, N) if (P[i] != A[i]) {
        printf(":(\n");
        return;
    }

    printf("%s\n", ans.c_str());
}