#import <Foundation/Foundation.h>
int main(){
    @autoreleasepool {
        int N;
        char C[102] = {'\0'};
        scanf("%d %s",&N,C);
        NSMutableString *s = [NSMutableString string];
        int v=0;
        for(int i=N-1;i>=0;i--){
            char c = C[i];
            if(c=='('){
                v--;
                if(v<0){
                    [s appendString:@")"];
                    v++;
                }
            } else {
                v++;
            }
            [s insertString:[NSString stringWithFormat:@"%c", c] atIndex:0];
        }
        for(int j=0;j<v;j++){
            [s insertString:@"(" atIndex:0];
        }
        puts(s.UTF8String);
    }
}
