Training Site
Sideways banner 8b44c02b768aa359c4d0a2bce3b247c6d7ab888f8b26852e9bfc3659c8c25612

Balancing Brackets

Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds

Greg is learning a dialect of Lisp that uses brackets, braces and parentheses but he is really bad at figuring out if they are balanced. He's asked you to write a program to help you figure out if everything is balanced.

Input

The first line will contain the single value 1 \le N \le 1000000, the length of Greg's program.

The next line will contain N characters and is the body of the program

Output

If all brackets, braces and parentheses are balanced output YES, otherwise output NO

  • Sample Input 1

    10
    (Hello[])a
    

    Sample Output 1

    YES
    
  • Sample Input 2

    10
    {Error!}[1
    

    Sample Output 2

    NO