import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { new Main().run(); } void run() throws FileNotFoundException { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String str = sc.next(); int[] pre = new int[N]; for (int i = 0; i < N; ++i) { pre[i] = i - 1; } int[] ans = new int[N]; for (int i = 0; i < N; ++i) { if (pre[i] >= 0 && str.charAt(i) == ')' && str.charAt(pre[i]) == '(') { ans[pre[i]] = i; ans[i] = pre[i]; if (i + 1 < N && pre[i] >= 0) pre[i + 1] = pre[pre[i]]; } } for (int i = 0; i < N; ++i) { System.out.println(ans[i] + 1); } } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }