import java.util.Scanner; class Main { static int top = 0, stack[] = new int[100000]; public static void push(int i) { stack[top] = i; ++top; } public static int pop() { --top; return stack[top]; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(), ans[] = new int[N], tmp; String S = sc.next(); sc.close(); for (int i = 0; i < N; ++i) { if (S.charAt(i) == '(') push(i); else { tmp = pop(); ans[i] = tmp + 1; ans[tmp] = i + 1; } } for (int i = 0; i < N; ++i) System.out.println(ans[i]); } }