For this Question: A robot is initially placed at the origin of the number line. The robot also has a happiness counter with an initial value of 0.

A command string is also given. Each character of this string denotes an operation on the robot. Each character of the string can be one of the following:

• 'C': Changes the robot's position by moving in either direction by one unit along the number line.

• '+': If the robot's current position is X, then add X to the happiness counter of the robot.

• '-': If the robot's current position is X, then subtract X from the happiness counter of the robot.

The robot will start executing the command string, i.e., it will execute each character one by one in the given order. However, the robot must return back to the origin after execution of the command string is finished. Thus, among all possible paths the robot can take, you must choose an assignment of directions in such a way that the robot finally ends up at the origin.
 
Note that the robot's coordinates and happiness can be negative while executing the string. Find the maximum possible happiness of the robot after executing the string.The first line of the input contains a single integer N (2 ≤ N ≤ 2×10<sup>5</sup>).
The next line contains the command string S of length N. The string only consists of characters '+', '-' and 'C'. The total number of appearances of 'C' in the string is guaranteed to be even.Print a single integer denoting the maximum possible happiness of the robot.Sample Input 1:
4
C-C-

Sample Output 1:
1

Sample Explanation 1:
There are only two possible paths the robot can take as it has to return to origin. The paths are 0 -> 1 -> 0 and 0 -> -1 -> 0. The path 0 -> -1 -> 0 gives the maximum happiness of 1.

Sample Input 2:
5
C+-C+

Sample Output 2:
0

Sample Explanation 2:
There are again only two possible paths the robot can take, both of which give happiness 0.

Sample Input 3:
6
C+CC-C

Sample Output 3:
2, I have written this Solution Code: import java.io.*;
import java.util.*;


public class Main {
    public static void main(String[] args) throws IOException {
        fs = new FastReader();
        out = new PrintWriter(System.out);
        int n = fs.nextInt();
        char s[] = fs.next().toCharArray();
        ArrayList<Integer> ar = new ArrayList<>();
        for (int i = n - 1, c = 0; i >= 0; --i) {
            if (s[i] == '+') ++c;
            else if (s[i] == '-') --c;
            else ar.add(c);
        }
        Collections.sort(ar);
        long ans = 0;
        for (int i = 0; i < ar.size(); ++i) {
            ans += i < ar.size() / 2 ? -ar.get(i) : ar.get(i);
        }
        out.println(ans);
        out.close();
    }

    public static PrintWriter out;
    public static FastReader fs;
    public static final Random random = new Random();

    public static void ruffleSort(int[] a) {
        int n = a.length;
        for (int i = 0; i < n; ++i) {
            int oi = random.nextInt(n), tmp = a[oi];
            a[oi] = a[i];
            a[i] = tmp;
        }
        Arrays.sort(a);
    }

    public static class FastReader {
        private BufferedReader br;
        private StringTokenizer st = new StringTokenizer("");

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String file_name) throws FileNotFoundException {
            br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(file_name))));
        }

        public String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i)
                a[i] = nextInt();
            return a;
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?