import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] arr = sc.next().toCharArray(); HashMap map = new HashMap<>(); int level = 0; int[] ans = new int[n]; for (int i = 0; i < n; i++) { if (arr[i] == '(') { level++; map.put(level, i); } else { int idx = map.get(level); ans[idx] = i + 1; ans[i] = idx + 1; level--; } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(ans[i]).append("\n"); } System.out.print(sb); } }