#include #include #include #include #include #include #include #include using namespace std; string S; int n; int main() { cin >> n >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == '(') { int depth = 0; for (int j = i; j < S.size(); j++) { if (S[j] == '(')depth++; else depth--; if (depth == 0) { cout << j + 1 << endl; break; } } } if (S[i] == ')') { int depth = 0; for (int j = i; j >= 0; j--) { if (S[j] == '(')depth++; else depth--; if (depth == 0) { cout << j + 1 << endl; break; } } } } return 0; }