import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Liavontsi Brechka
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static
    @SuppressWarnings("Duplicates")
    class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String number = in.next();
            int n = number.length();
            boolean isNegative = number.charAt(0) == '-';
            StringBuilder res = new StringBuilder();
            int i = number.indexOf('.') - 1;
            if (i == -2) i = n - 1;
            int j = 0;
            while (i > (isNegative ? 0 : -1)) {
                if (j == 3) {
                    res.append(',');
                    j = 0;
                }
                j++;
                res.append(number.charAt(i--));
            }

            res.append('$');
            if (isNegative) res.append('(');
            res.reverse();
            res.append('.');
            i = number.indexOf('.') + 1;
            if (i != 0) {
                j = 0;
                while (j++ < 2) {
                    if (i < n) res.append(number.charAt(i++));
                    else res.append('0');
                }
            } else {
                res.append("00");
            }
            if (isNegative) res.append(')');
            out.print(res);
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}


import java.io.*;
import java.util.*;
public class cdf102b
{
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		int f=0;
		if(s.charAt(0)=='-')
		{
			f=1;
			s=s.substring(1);
		}
		int l=s.length();
		String ans="";
		int k=0;
		int pos=s.indexOf('.');
		l--;
		if(pos>0)
		{
			String a1=s.substring(0,pos);
			String a2=s.substring(pos+1);
			int l1=a1.length()-1;
			while(l1>=0)
			{
				k++;
				ans=s.charAt(l1)+ans;
				l1--;
				if(k==3&&l1>=0)
				{
					ans=","+ans;
					k=0;
				}
			}
			ans=ans+".";
			if(a2.length()==1)
			ans=ans+a2+"0";
			else if(a2.length()==0)
			ans=ans+"00";
			else
			ans=ans+a2.substring(0,2);
			ans="$"+ans;
			if(f==1)
			ans="("+ans+")";
			System.out.println(ans);
		}
		else
		{
			while(l>=0)
			{
				k++;
				ans=s.charAt(l)+ans;
				l--;
				if(k==3&&l>=0)
				{
					ans=","+ans;
					k=0;
				}

			}
			ans="$"+ans;
			if(f==1)
			ans="("+ans+".00)";
			else
			ans=ans+".00";
			System.out.println(ans);
		}
	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.BitSet;
public class A {

		    public static void main(String[] args) throws IOException {
		    	FastReader sc=new FastReader();
		    	String s=sc.next();
		    	String sfinal="";
		    	boolean ifminus=s.contains("-");
		    	if(ifminus) s=s.substring(1, s.length());
		    	int indexOfdot=s.length();
		    	if(s.contains(".")) indexOfdot=s.indexOf(".");
		    	int c=0;
		    	String s3="";
		    	for(int i=indexOfdot-1;i>=0;i--){
		    		if(c==3){
		    			s3=s3+","+s.charAt(i);
		    			c=1;

		    		}
		    		else {
		    			s3=s3+s.charAt(i);
		    		    c++;
		    		}

		    	}
		    	String s1=new StringBuilder(s3).reverse().toString();
		          if(ifminus) sfinal+="($"+s1;
		          else sfinal+="$"+s1;
		          if(s.contains(".")){
		        	  sfinal+="."+s.charAt(indexOfdot+1);
		        	  if(indexOfdot+2<=s.length()-1) sfinal+=s.charAt(indexOfdot+2);
		        	  else sfinal+="0";

		          }
		          else {
		        	  sfinal+=".00";
		          }
		          if(ifminus) sfinal+=")";
		          System.out.println(sfinal);

		     }

       static class FastReader
		    {
		        BufferedReader br;
		        StringTokenizer st;

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

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

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

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

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

		        String nextLine()
		        {
		            String str = "";
		            try
		            {
		                str = br.readLine();
		            }
		            catch (IOException e)
		            {
		                e.printStackTrace();
		            }
		            return str;
		        }
		    }
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author lpeter83
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        StringBuilder sb = new StringBuilder();
        char[] s = in.next().toCharArray();
        sb.append("$");
        int cnt = 0, idx = 0;
        boolean deci = false;
        boolean min = false;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '-') {
                min = true;
                continue;
            }
            if (deci) {
                cnt++;
            }
            if (s[i] == '.') deci = true;
            if (cnt > 2) break;
            sb.append(s[i]);

        }
        //out.printLine(cnt);
        if (cnt == 1) sb.append("0");
        if (!deci) sb.append(".00");

        idx = sb.indexOf(".");
        //out.printLine(idx);
        while (idx - 3 > 0) {
           sb.insert(idx - 3,',');
            idx -= 3;
        }

        if (min) {
            sb.insert(0,"(");
            sb.insert(sb.length(),")");
        }

        out.printLine(sb.toString());
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author lpeter83
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        StringBuilder sb = new StringBuilder();
        char[] s = in.next().toCharArray();
        sb.append("$");
        int cnt = 0, idx = 0;
        boolean deci = false;
        boolean min = false;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '-') {
                min = true;
                continue;
            }
            if (deci) {
                cnt++;
            }
            if (s[i] == '.') deci = true;
            if (cnt > 2) break;
            sb.append(s[i]);

        }
        //out.printLine(cnt);
        if (cnt == 1) sb.append("0");
        if (!deci) sb.append(".00");
        if (deci && cnt == 0) sb.append("00");

        idx = sb.indexOf(".");
        //out.printLine(idx);
        while (idx - 3 > 1) {
           sb.insert(idx - 3,',');
            idx -= 3;
        }

        if (min) {
            sb.insert(0,"(");
            sb.insert(sb.length(),")");
        }

        out.printLine(sb.toString());
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author lpeter83
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        StringBuilder sb = new StringBuilder();
        char[] s = in.next().toCharArray();
        sb.append("$");
        int cnt = 0, idx = 0;
        boolean deci = false;
        boolean min = false;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '-') {
                min = true;
                continue;
            }
            if (deci) {
                cnt++;
            }
            if (s[i] == '.') deci = true;
            if (cnt > 2) break;
            sb.append(s[i]);

        }
        //out.printLine(cnt);
        if (cnt == 1) sb.append("0");
        if (cnt == 0) sb.append(".00");

        idx = sb.indexOf(".");
        //out.printLine(idx);
        while (idx - 3 > 0) {
           sb.insert(idx - 3,',');
            idx -= 3;
        }

        if (min) {
            sb.insert(0,"(");
            sb.insert(sb.length(),")");
        }

        out.printLine(sb.toString());
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author lpeter83
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        StringBuilder sb = new StringBuilder();
        char[] s = in.next().toCharArray();
        sb.append("$");
        int cnt = 0, idx = 0;
        boolean deci = false;
        boolean min = false;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '-') {
                min = true;
                continue;
            }
            if (deci) {
                cnt++;
            }
            if (s[i] == '.') deci = true;
            if (cnt > 2) break;
            sb.append(s[i]);

        }
        //out.printLine(cnt);
        if (cnt == 1) sb.append("0");
        if (!deci) sb.append(".00");
        if (deci && cnt == 0) sb.append("00");

        idx = sb.indexOf(".");
        //out.printLine(idx);
        while (idx - 3 > 0) {
           sb.insert(idx - 3,',');
            idx -= 3;
        }

        if (min) {
            sb.insert(0,"(");
            sb.insert(sb.length(),")");
        }

        out.printLine(sb.toString());
    }
}

class InputReader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		String ans2 = "";
		double n = Double.valueOf(z);
		if(Double.valueOf(z)==1 && z.charAt(0)!='1'){
			n--;
		}
		int cur = Integer.valueOf(z.substring(0, z.indexOf('.')));
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				c++;
			}
			if(lol>0)System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){cur = Integer.valueOf(z.substring(0, z.indexOf('.')));}else{
			 cur =(int)n;
		}
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		int tt=lol;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				c++;
			}
			if(tt>0)System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){cur = Integer.valueOf(z.substring(0, z.indexOf('.')));}else{
			 cur =(int)n;
		}
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				c++;
			}
			if(c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z=nextToken();
		String ans="";
		String ans2="";
		boolean f=false;
		double n=Double.valueOf(z);
		int cur =Math.abs((int ) n);
		 ans2+=cur;
		ans+=cur;

		int lol= ans2.length() % 3 ;
		if(n<0){
			System.out.print('(');
		}
	  System.out.print('$');
	  int c=0;
	  if(cur>0){
	  while(lol-->0){
		  System.out.print(ans.charAt(c));
		  c++;
	  }
	  System.out.print(',');
	  int u=0;
	  while(c<ans.length()){
		  u++;
		  System.out.print(ans.charAt(c));
		  c++;
		  if( (u % 3==0 && u>=3 && ans.length()-c!=0)){
			  System.out.print(',');
		  }
	  }
	}else{
		  f=true;
		  System.out.print(0);
	}
	  if (!z.contains(".")) {
          System.out.println(".00");
  } else {
          z += "0";
         System.out.print(z.substring(z.indexOf('.'), z.indexOf('.')+3));
  }

	  if(n<0){
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){cur = Integer.valueOf(z.substring(0, z.indexOf('.')));}else{
			 cur =(int)n;
		}
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f && c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.print(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		String ans2 = "";
		double n = Double.valueOf(z);
		if(Double.valueOf(z)==1 && z.charAt(0)!='1'){
			n--;
		}
		int cur = (int) n;
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				c++;
			}
			System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){cur = Integer.valueOf(z.substring(0, z.indexOf('.')));}else{
			 cur =(int)n;
		}
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f && c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){ans = z.substring(0, z.indexOf('.'));}else{
			 ans+=n;
		}
		cur=Math.abs(ans.length());
		ans2 += ans;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f && c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.print(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){if(n>0){ans = z.substring(0, z.indexOf('.'));}else{ans = z.substring(1, z.indexOf('.'));}}else{
		ans=z;
		if(z.charAt(0)=='-'){
			ans=ans.substring(1,ans.length());
		}
		}

		cur=Math.abs(ans.length());
		ans2 = ans;
		int lol = ans.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f && c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.print(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){ans = z.substring(0, z.indexOf('.'));}else{
			 ans+= (int)n;
		}
		cur=Math.abs(ans.length());
		ans2 = ans;
		int lol = ans.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f && c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.print(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){ans = z.substring(0, z.indexOf('.'));}else{

			int v= ((Math.abs((int)n)));
		if(v>0){ans+=v;}else{v=-v;ans+=v;}
		}
		cur=Math.abs(ans.length());
		ans2 = ans;
		int lol = ans.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if(ans.charAt(0)=='-'){
			c++;
			lol--;
		}
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f && c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.print(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){cur = Integer.valueOf(z.substring(0, z.indexOf('.')));}else{
			 cur =(int)n;
		}
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f)System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		boolean f=false;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){if(n>0){ans = z.substring(0, z.indexOf('.'));}else{ans = z.substring(1, z.indexOf('.'));}}else{
			int v= ((Math.abs((int)n)));
		if(v>0){ans+=v;}else{v=-v;ans+=v;}
		}

		cur=Math.abs(ans.length());
		ans2 = ans;
		int lol = ans.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				f=true;
				c++;
			}
			if(f && c!=ans.length())System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.print(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z=nextToken();
		String ans="";
		String ans2="";
		boolean f=false;
		double n=Double.valueOf(z);
		System.out.println(n);
		int cur =Math.abs((int ) n);
		 ans2+=cur;
		ans+=cur;

		int lol= ans2.length() % 3 ;
		if(n<0){
			System.out.print('(');
		}
	  System.out.print('$');
	  int c=0;
	  if(cur>0){
	  while(lol-->0){
		  System.out.print(ans.charAt(c));
		  c++;
	  }
	  System.out.print(',');
	  int u=0;
	  while(c<ans.length()){
		  u++;
		  System.out.print(ans.charAt(c));
		  c++;
		  if( (u % 3==0 && u>=3 && ans.length()-c!=0)){
			  System.out.print(',');
		  }
	  }
	}else{
		  f=true;
		  System.out.print(0);
	}
	  if (!z.contains(".")) {
          System.out.println(".00");
  } else {
          z += "0";
         System.out.print(z.substring(z.indexOf('.'), z.indexOf('.')+3));
  }

	  if(n<0){
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		int cur=0;
		String ans2 = "";
		double n = Double.valueOf(z);
		if(z.contains(".")){cur = Integer.valueOf(z.substring(0, z.indexOf('.')));}else{
			 cur =(int)n;
		}
		cur=Math.abs(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				c++;
			}
			if(lol>0)System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class B {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		String z = nextToken();
		String ans = "";
		String ans2 = "";
		double n = Double.valueOf(z);
		if(Double.valueOf(z)==1 && z.charAt(0)!='1'){
			n--;
		}
		System.out.println(n);
		int cur = (int) n;
		cur=Math.abs(cur);
		System.out.println(cur);
		ans2 += cur;
		ans += cur;

		int lol = ans2.length() % 3;
		if (n < 0) {
			System.out.print('(');
		}
		System.out.print('$');
		int c = 0;
		if (cur > 0) {
			while (lol-- > 0) {
				System.out.print(ans.charAt(c));
				c++;
			}
			System.out.print(',');
			int u = 0;
			while (c < ans.length()) {
				u++;
				System.out.print(ans.charAt(c));
				c++;
				if ((u % 3 == 0 && u >= 3 && ans.length() - c != 0)) {
					System.out.print(',');
				}
			}
		} else {
			System.out.print(0);
		}
		if (!z.contains(".")) {
			System.out.println(".00");
		} else {
			z += "0";
			System.out.print(z.substring(z.indexOf('.'), z.indexOf('.') + 3));
		}

		if (n < 0) {
			System.out.print(')');
		}
	}

	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public static void main(String args[]) throws IOException {
		new B().solution();
	}
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, InputReader in, PrintWriter out) {

        String s = in.next();
        String ret = "";
        boolean flag = false;
        int start = 0;
        if(s.charAt(0)=='-'){
            ret += "(";
            start++;
            flag = true;
        }
        ret+="$";
        int index = s.indexOf(".");

        if(index>0){
            String x = "";
            int count = 0;
            for(int i=index-1;i>=start;i--){
                count++;
                x = s.charAt(i) + x;
                if(count==3 && i!=start)
                {
                    x = ","+x;
                    count = 0;
                }
            }
            ret += x;
            ret += ".";
            index++;
            count = 0;
            for(int i=0;i<2;i++){
                if(index<s.length()){
                    ret += s.charAt(index);
                    count++;
                    index++;
                }
            }
            for(int i=count;i<2;i++)
                ret+=0;
            if(flag)
                ret += ")";
        }
        else{
            String x = "";
            int count = 0;
            for(int i=s.length()-1;i>=start;i--){
                count++;
                x = s.charAt(i) + x;
                if(count==3 && i!=start)
                {
                    x = ","+x;
                    count = 0;
                }
            }
            ret += x;
            ret += ".00";
            if(flag)
                ret+=")";

        }
        out.println(ret);
	}
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    }


import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, InputReader in, PrintWriter out) {

        String s = in.next();
        if(s.length()==1){
            out.println("$"+s);
            return;
        }
        String ret = "";
        boolean flag = false;
        int start = 0;
        if(s.charAt(0)=='-'){
            ret += "(";
            start++;
            flag = true;
        }
        ret+="$";
        int index = s.indexOf(".");

        if(index>0){
            String x = "";
            int count = 0;
            for(int i=index-1;i>=start;i--){
                count++;
                x = s.charAt(i) + x;
                if(count==3 && i!=start)
                {
                    x = ","+x;
                    count = 0;
                }
            }
            ret += x;
            ret += ".";
            index++;
            count = 0;
            for(int i=0;i<2;i++){
                if(index<s.length()){
                    ret += s.charAt(index);
                    count++;
                    index++;
                }
            }
            for(int i=count;i<2;i++)
                ret+=0;
            if(flag)
                ret += ")";
        }
        else{
            String x = "";
            int count = 0;
            for(int i=s.length()-1;i>=start;i--){
                count++;
                x = s.charAt(i) + x;
                if(count==3 && i!=start)
                {
                    x = ","+x;
                    count = 0;
                }
            }
            ret+=x;
            ret += ".00";
            if(flag)
                ret+=")";

        }
        out.println(ret);
	}
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    }


import java.io.*;
import java.util.*;

public class CodeForces {

	public void solve() throws IOException {
		String str = nextToken();
		StringBuffer sb = new StringBuffer();
		int ind = str.indexOf(".");
		int c = 0;
		if (str.charAt(0) == '-') {
			sb.append("(");
			c = 1;
		}
		sb.append("$");

		if (ind == -1)
			ind = str.length();
		int t = (ind - c) % 3;
		while (t-- > 0) {
			sb.append(str.charAt(c++));
		}
		if((ind - c) % 3!=0){
			sb.append(",");
		}
		while (c < ind) {
			sb.append(str.charAt(c++));
			sb.append(str.charAt(c++));
			sb.append(str.charAt(c++));
			sb.append(",");
		}
		sb.deleteCharAt(sb.length()-1);
		sb.append(".");
		if (str.indexOf(".") != -1) {
			c++;
			if(str.length()-str.indexOf(".")>=3){
				sb.append(str.charAt(c++)).append(str.charAt(c++));
			} else {
				sb.append(str.charAt(c++)).append("0");
			}
		} else {
			sb.append("0").append("0");
		}

		if (str.charAt(0) == '-') {
			sb.append(")");
		}
		out.print(sb.toString());
	}

	public static void main(String[] args) {
		new CodeForces().run();
	}

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new BufferedWriter(new FileWriter(
						"output.txt")));
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;
			// long time = new Date().getTime();
			solve();
			// out.println(time - new Date().getTime());
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.io.*;
import java.util.*;

public class CodeForces {

	public void solve() throws IOException {
		String str = nextToken();
		StringBuffer sb = new StringBuffer();
		int ind = str.indexOf(".");
		int c = 0;
		if (str.charAt(0) == '-') {
			sb.append("(");
			c = 1;
		}
		sb.append("$");

		if (ind == -1)
			ind = str.length();
		int t = (ind - c) % 3;
		while (t-- > 0) {
			sb.append(str.charAt(c++));
		}
		sb.append(",");
		while (c < ind) {
			sb.append(str.charAt(c++));
			sb.append(str.charAt(c++));
			sb.append(str.charAt(c++));
			sb.append(",");
		}
		sb.deleteCharAt(sb.length()-1);
		sb.append(".");
		if (str.indexOf(".") != -1) {
			c++;
			if(str.length()-str.indexOf(".")>=3){
				sb.append(str.charAt(c++)).append(str.charAt(c++));
			} else {
				sb.append(str.charAt(c++)).append("0");
			}
		} else {
			sb.append("0").append("0");
		}

		if (str.charAt(0) == '-') {
			sb.append(")");
		}
		out.print(sb.toString());
	}

	public static void main(String[] args) {
		new CodeForces().run();
	}

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new BufferedWriter(new FileWriter(
						"output.txt")));
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;
			// long time = new Date().getTime();
			solve();
			// out.println(time - new Date().getTime());
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.io.*;
import java.util.*;

public class CodeForces {

	public void solve() throws IOException {
		String str = nextToken();
		StringBuffer sb = new StringBuffer();
		int ind = str.indexOf(".");
		int c = 0;
		if (str.charAt(0) == '-') {
			sb.append("(");
			c = 1;
		}
		sb.append("$");

		if (ind == -1)
			ind = str.length();
		if ((ind - c) % 3 != 0) {
			int t = (ind - c) % 3;
			while (t-- > 0) {
				sb.append(str.charAt(c++));
			}

			sb.append(",");
		}
		while (c < ind) {
			sb.append(str.charAt(c++));
			sb.append(str.charAt(c++));
			sb.append(str.charAt(c++));
			sb.append(",");
		}
		sb.deleteCharAt(sb.length() - 1);
		sb.append(".");
		if (str.indexOf(".") != -1) {
			c++;
			if (str.length() - str.indexOf(".") >= 3) {
				sb.append(str.charAt(c++)).append(str.charAt(c++));
			} else {
				sb.append(str.charAt(c++)).append("0");
			}
		} else {
			sb.append("0").append("0");
		}

		if (str.charAt(0) == '-') {
			sb.append(")");
		}
		out.print(sb.toString());
	}

	public static void main(String[] args) {
		new CodeForces().run();
	}

	int NOD(int a, int b) {
		while (a != 0 && b != 0) {
			if (a >= b)
				a = a % b;
			else
				b = b % a;
		}
		return a + b;
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	boolean isOuterFile = false;

	public void run() {
		try {
			if (isOuterFile) {
				reader = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter(new BufferedWriter(new FileWriter(
						"output.txt")));
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			tokenizer = null;
			// long time = new Date().getTime();
			solve();
			// out.println(time - new Date().getTime());
			reader.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        if (s.contains(".")) {
            s = s.replace(".", " ");
            String[] num = s.split("[ ]");
            String ret = intPart(num[0]) +"."+dpart(num[1]);
            if(s.contains("-"))
                ret = ret.substring(1);
            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        } else {
            String ret = intPart(s) + ".00";
            if(s.contains("-"))
                ret = ret.substring(1);
            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        }
    }

    public static String intPart(String s) {
        StringBuilder sb = new StringBuilder(s);
        int a = 0;
        for (int i = sb.length() - 1; i >= 0; i--) {
            if (a % 3 == 0 && a != 0)
                sb.insert(i + 1, ",");
            a++;
        }
        return sb.toString();
    }

    public static String dpart(String s) {
        if (s.length() >= 2)
            return s.substring(0, 2);
        return s + "0";
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        if (s.contains(".")) {
            s = s.replace(".", " ");
            String[] num = s.split("[ ]");
            String ret;
            if (s.contains("-"))
                ret = intPart(num[0]) + "." + dpart(num[1]);
            else
                ret = intPart(num[0].substring(1)) + "." + dpart(num[1]);
            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        } else {
            String ret;
            if (s.contains("-"))
                ret = intPart(s.substring(1)) + ".00";
            else
                ret = intPart(s) + ".00";
            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        }
    }

    public static String intPart(String s) {
        StringBuilder sb = new StringBuilder(s);
        int a = 0;
        for (int i = sb.length() - 1; i >= 0; i--) {
            if (a % 3 == 0 && a != 0)
                sb.insert(i + 1, ",");
            a++;
        }
        return sb.toString();
    }

    public static String dpart(String s) {
        if (s.length() >= 2)
            return s.substring(0, 2);
        return s + "0";
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        if (s.contains(".")) {
            s = s.replace(".", " ");
            String[] num = s.split("[ ]");
            String ret = intPart(num[0]) +"."+dpart(num[1]);
            if(s.contains("-"))
                ret = ret.substring(1);
            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        } else {
            String ret = intPart(s) + ".00";
            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        }
    }

    public static String intPart(String s) {
        StringBuilder sb = new StringBuilder(s);
        int a = 0;
        for (int i = sb.length() - 1; i >= 0; i--) {
            if (a % 3 == 0 && a != 0)
                sb.insert(i + 1, ",");
            a++;
        }
        return sb.toString();
    }

    public static String dpart(String s) {
        if (s.length() >= 2)
            return s.substring(0, 2);
        return s + "0";
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        if (s.contains(".")) {
            s = s.replace(".", " ");
            String[] num = s.split("[ ]");
            String ret;
            if (s.contains("-"))
                ret = intPart(num[0].substring(1)) + "." + dpart(num[1]);
            else
                ret = intPart(num[0]) + "." + dpart(num[1]);

            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        } else {
            String ret;
            if (s.contains("-"))
                ret = intPart(s.substring(1)) + ".00";
            else
                ret = intPart(s) + ".00";
            if (ret.equals("0.00")) {
                if (s.contains("-"))
                    System.out.println("($0.00)");
                else
                    System.out.println("$0.00");
            } else {
                if (s.contains("-"))
                    System.out.println("($" + ret + ")");
                else
                    System.out.println("$" + ret);
            }
        }
    }

    public static String intPart(String s) {
        StringBuilder sb = new StringBuilder(s);
        int a = 0;
        for (int i = sb.length() - 1; i >= 0; i--) {
            if (a % 3 == 0 && a != 0)
                sb.insert(i + 1, ",");
            a++;
        }
        return sb.toString();
    }

    public static String dpart(String s) {
        if (s.length() >= 2)
            return s.substring(0, 2);
        return s + "0";
    }
}


import java.math.*;
import java.util.*;

public class cc {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String d = sc.next();

		String aa, bb = "";
		if (d.indexOf(".") > 0) {
			aa = d.substring(0, d.indexOf("."));
			bb = d.substring(d.indexOf(".") + 1, d.length());

			if (bb.length() == 1) {
				bb += "0";
			} else if (bb.length() == 0) {
				bb = "00";
			} else {
				bb = bb.substring(0, 2);
			}

			if (aa.charAt(0) != '-') {
				for (int i = aa.length() - 4; i >= 0 && aa.length() != 3; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "$" + aa + "." + bb;
			} else {
				aa = aa.substring(1, aa.length());
				for (int i = aa.length() - 4; i >= 0 && aa.length() != 3; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "($" + aa + "." + bb + ")";

			}

		} else {
			aa = d;
			if (aa.charAt(0) != '-') {
				for (int i = aa.length() - 4; i >= 0 && aa.length() != 3; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "$" + aa;
			} else {
				aa = aa.substring(1, aa.length());
				for (int i = aa.length() - 4; i >= 0 && aa.length() != 3; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "($" + aa  + ")";

			}
		}
		System.out.print(aa);
	}
}


import java.math.*;
import java.util.*;

public class cc {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String d = sc.next();

		String aa, bb = "";
		if (d.indexOf(".") > 0) {
			aa = d.substring(0, d.indexOf("."));
			bb = d.substring(d.indexOf(".") + 1, d.length());

			if (bb.length() == 1) {
				bb += "0";
			} else if (bb.length() == 0) {
				bb = "00";
			} else {
				bb = bb.substring(0, 2);
			}

			if (aa.charAt(0) != '-') {
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "$" + aa + "." + bb;
			} else {
				aa = aa.substring(1, aa.length());
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "($" + aa + "." + bb + ")";

			}

		} else {
			aa = d;
			if (aa.charAt(0) != '-') {
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "$" + aa + "."+ "00";
			} else {
				aa = aa.substring(1, aa.length());
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "($" + aa  + "."+ "00" +  ")";

			}
		}
		System.out.print(aa);
	}
}


import java.math.*;
import java.util.*;

public class cc {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String d = sc.next();

		String aa, bb = "";
		if (d.indexOf(".") > 0) {
			aa = d.substring(0, d.indexOf("."));
			bb = d.substring(d.indexOf(".") + 1, d.length());

			if (bb.length() == 1) {
				bb += "0";
			} else if (bb.length() == 0) {
				bb = "00";
			} else {
				bb = bb.substring(0, 2);
			}

			if (aa.charAt(0) != '-') {
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "$" + aa + "." + bb;
			} else {
				aa = aa.substring(1, aa.length());
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "($" + aa + "." + bb + ")";

			}

		} else {
			aa = d;
			if (aa.charAt(0) != '-') {
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "$" + aa;
			} else {
				aa = aa.substring(1, aa.length());
				for (int i = aa.length() - 4; i >= 0; i-=3) {
					aa = aa.substring(0, i + 1) + "," + aa.substring(i + 1, aa.length());
				}
				aa = "($" + aa  + ")";

			}
		}
		System.out.print(aa);
	}
}


import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.lang.*;
import java.lang.reflect.Array;
import java.nio.charset.Charset;

public class test {

	public static void main(String[] args) throws Exception {

		String s = inB.readLine();
		String ans = "";
		boolean isNeg = false;
		boolean isDot = false;
		if(s.charAt(0) == '-'){
			isNeg = true;
			s = s.substring(1);
		}
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) != '.') ans += s.charAt(i);
			else{
				isDot = true;
				ans += ".";
				i++;
				if(i < s.length()) ans += s.charAt(i);
				else ans += "0";
				i++;
				if(i < s.length()) ans += s.charAt(i);
				else ans += "0";
				break;
			}
		}
		if(!isDot) ans += ".00";
		int k = 0;
		for(int i = ans.length() - 4; i >= 0; i--){
			k++;
			if(k == 3){
				k = 0;
				ans = ans.substring(0, i) + "," + ans.substring(i);
			}
		}
		ans = "$" + ans;
		if(isNeg){
			ans = "(" + ans;
			ans = ans + ")";
		}
		exit(ans);
	}

		private static PrintWriter out = new PrintWriter(System.out);
        private static BufferedReader inB = new BufferedReader(new InputStreamReader(System.in));
        private static StreamTokenizer in = new StreamTokenizer(inB);

        private static void exit(Object o) throws Exception {
        	out.println(o);
        	out.flush();
        	System.exit(0);
        }
        private static void println(Object o) throws Exception{
        	out.println(o);
        	out.flush();
        }
        private static int nextInt() throws Exception {
        	in.nextToken();
        	return (int)in.nval;
        }
        private static String nextString() throws Exception {
        	in.nextToken();
        	return in.sval;
        }
}


import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.lang.*;
import java.lang.reflect.Array;
import java.nio.charset.Charset;

public class test {

	public static void main(String[] args) throws Exception {

		String s = inB.readLine();
		String ans = "";
		boolean isNeg = false;
		boolean isDot = false;
		if(s.charAt(0) == '-'){
			isNeg = true;
			s = s.substring(1);
		}
		for(int i = 0; i < s.length(); i++){
			if(s.charAt(i) != '.') ans += s.charAt(i);
			else{
				isDot = true;
				ans += ".";
				i++;
				if(i < s.length()) ans += s.charAt(i);
				else ans += "0";
				i++;
				if(i < s.length()) ans += s.charAt(i);
				else ans += "0";
				break;
			}
		}
		if(!isDot) ans += ".00";
		int k = 0;
		for(int i = ans.length() - 4; i >= 0; i--){
			k++;
			if(k == 3 && i != 0){
				k = 0;
				ans = ans.substring(0, i) + "," + ans.substring(i);
			}
		}
		ans = "$" + ans;
		if(isNeg){
			ans = "(" + ans;
			ans = ans + ")";
		}
		exit(ans);
	}

		private static PrintWriter out = new PrintWriter(System.out);
        private static BufferedReader inB = new BufferedReader(new InputStreamReader(System.in));
        private static StreamTokenizer in = new StreamTokenizer(inB);

        private static void exit(Object o) throws Exception {
        	out.println(o);
        	out.flush();
        	System.exit(0);
        }
        private static void println(Object o) throws Exception{
        	out.println(o);
        	out.flush();
        }
        private static int nextInt() throws Exception {
        	in.nextToken();
        	return (int)in.nval;
        }
        private static String nextString() throws Exception {
        	in.nextToken();
        	return in.sval;
        }
}


import java.io.*;
import java.util.*;

public class Main {

    public static void main (String [] args) throws IOException {
	BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
	String s = in.readLine ();

	double d = Double.parseDouble (s);
	if (s.length () > 0 && s.charAt (0) == '-')
	    s = s.substring (1);
	String ret = "$";
	String money = "";
	String first = "";
	int i = 0;
	for (; i < s.length (); ++i) {
	    if (s.charAt (i) != '.')
		money += s.charAt (i);
	    else
		break;
	}
	for (int j = money.length () - 1; j >= 0; --j) {
	    first = money.charAt (j) + first;
	    if ((money.length () - j) % 3 == 0)
		first = "," + first;
	}
	ret += first;
	String last = "";
	int counter = 0;
	++i;
	for (;i < s.length () && counter < 2; ++i) {
	    counter++;
	    last += s.charAt (i);
	}
	while (last.length () < 2)
	    last += "0";
	ret += ".";
	ret += last;
	if (d < 0) {
	    ret = "(" + ret + ")";
	}
	System.out.println (ret);
    }
}


import java.io.*;
import java.util.*;

public class Main {

    public static void main (String [] args) throws IOException {
	BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
	String s = in.readLine ();
	boolean brack = false;
	if (s.length () > 0 && s.charAt (0) == '-') {
	    brack = true;
	    s = s.substring (1);
	}
	String ret = "$";
	String money = "";
	String first = "";
	int i = 0;
	for (; i < s.length (); ++i) {
	    if (s.charAt (i) != '.')
		money += s.charAt (i);
	    else
		break;
	}
	for (int j = money.length () - 1; j >= 0; --j) {
	    first = money.charAt (j) + first;
	    if ((money.length () - j) % 3 == 0)
		first = "," + first;
	}
	ret += first;
	String last = "";
	int counter = 0;
	++i;
	for (;i < s.length () && counter < 2; ++i) {
	    counter++;
	    last += s.charAt (i);
	}
	while (last.length () < 2)
	    last += "0";
	ret += ".";
	ret += last;
	if (brack) {
	    ret = "(" + ret + ")";
	}
	System.out.println (ret);
    }
}


import java.io.*;
import java.util.*;

public class Main
{

    public static void main (String[] args) throws IOException
    {
	BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
	String s = in.readLine ();
	boolean brack = false;
	if (s.length () > 0 && s.charAt (0) == '-')
	{
	    brack = true;
	    s = s.substring (1);
	}
	String ret = "$";
	String money = "";
	String first = "";
	int i = 0;
	for (; i < s.length () ; ++i)
	{
	    if (s.charAt (i) != '.')
		money += s.charAt (i);
	    else
		break;
	}
	for (int j = money.length () - 1 ; j >= 0 ; --j)
	{
	    first = money.charAt (j) + first;
	    if ((money.length () - j) % 3 == 0 && j != 0)
		first = "," + first;
	}
	ret += first;
	String last = "";
	int counter = 0;
	++i;
	for (; i < s.length () && counter < 2 ; ++i)
	{
	    counter++;
	    last += s.charAt (i);
	}
	while (last.length () < 2)
	    last += "0";
	ret += ".";
	ret += last;
	if (brack)
	{
	    ret = "(" + ret + ")";
	}

	System.out.println (ret);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution {
	void solve() throws IOException {
		String sum = nextToken();
		int dot = sum.indexOf('.');
		boolean sign = false;
		if (dot != -1) {
			if (sum.length() - dot - 1 == 1)
				sum += "0";
			else if (sum.length() - dot - 1 > 2)
				sum = sum.substring(0, dot + 3);
		} else {
			dot = sum.length();
			sum += ".00";
		}
		if (sum.charAt(0) == '-') {
			dot--;
			sign = true;
			sum = sum.substring(1);
		}
		for (int i = dot - 3; i >= 0; i -= 3)
			sum = sum.substring(0, i) + "," + sum.substring(i);
		sum = "$" + sum;
		if (sign)
			sum = "(" + sum + ")";
		System.out.println(sum);
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null)
				return "-1";
			st = new StringTokenizer(s);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		br.close();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Solution().run();
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution {
	void solve() throws IOException {
		String sum = nextToken();
		int dot = sum.indexOf('.');
		boolean sign = false;
		if (dot != -1) {
			if (sum.length() - dot - 1 == 1)
				sum += "0";
			else if (sum.length() - dot - 1 > 2)
				sum = sum.substring(0, dot + 3);
		} else {
			dot = sum.length();
			sum += ".00";
		}
		if (sum.charAt(0) == '-') {
			dot--;
			sign = true;
			sum = sum.substring(1);
		}
		for (int i = dot - 3; i > 0; i -= 3)
			sum = sum.substring(0, i) + "," + sum.substring(i);
		sum = "$" + sum;
		if (sign)
			sum = "(" + sum + ")";
		System.out.println(sum);
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null)
				return "-1";
			st = new StringTokenizer(s);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		br.close();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Solution().run();
	}

}


import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.text.DecimalFormat;
import static java.lang.System.*;

public class uang {

    static BufferedReader br;

    public static void init() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public static String getString() {
        try {
            if (br == null) {
                init();
            }
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            if (br == null) {
                init();
            }
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            if (br == null) {
                init();
            }
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void main(String[] ar) {
        String s[] = getString().split("\\.");
        DecimalFormat dd = new DecimalFormat("$0,000");
        String ss = "";
        BigInteger bi = new BigInteger(s[0]);
        //System.out.println(bi.compareTo(new BigInteger("999999999999")));

        if (bi.abs().compareTo(new BigInteger("999"))>0) {
            ss = dd.format(bi);
        } else {
            ss = "$" + s[0];
        }
        String ss2 = "";
        if (s.length == 1) {
            ss2=".00";
        } else {
            if (s[1].length() < 2) {
                s[1] += "00";
            }
            for (int i = 0; i < 2; i++) {
                ss2 += s[1].charAt(i);
            }
            ss2 = "." + ss2;
        }
        if (ss.contains("-")) {
            ss = "(" + ss.replace("-", "") + ss2 + ")";

        }else{
            ss=ss+ss2;
        }

        System.out.println(ss);

    }
}


import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import static java.lang.System.*;

public class uang {

    static BufferedReader br;

    public static void init() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public static String getString() {
        try {
            if (br == null) {
                init();
            }
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            if (br == null) {
                init();
            }
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            if (br == null) {
                init();
            }
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void main(String[] ar) {
        String s[] = getString().split("\\.");
        DecimalFormat dd = new DecimalFormat("$0,000");
        String ss = "";
        if (Math.abs(Integer.parseInt(s[0])) > 999) {
            ss = dd.format(Integer.parseInt(s[0]));
        } else {
            ss = "$" + s[0];
        }
        String ss2 = "";
        if (s.length == 1) {
            ss2="00";
        } else {
            if (s[1].length() < 2) {
                s[1] += "00";
            }
            for (int i = 0; i < 2; i++) {
                ss2 += s[1].charAt(i);
            }
            ss2 = "." + ss2;
        }
        if (ss.contains("-")) {
            ss = "(" + ss.replace("-", "") + ss2 + ")";

        }else{
            ss=ss+ss2;
        }

        System.out.println(ss);
    }
}


import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import static java.lang.System.*;

public class uang {

    static BufferedReader br;

    public static void init() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public static String getString() {
        try {
            if (br == null) {
                init();
            }
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            if (br == null) {
                init();
            }
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            if (br == null) {
                init();
            }
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void main(String[] ar) {
        String s[] = getString().split("\\.");
        DecimalFormat dd = new DecimalFormat("$0,000");
        String ss = "";
        if (Math.abs(Integer.parseInt(s[0])) > 999) {
            ss = dd.format(Integer.parseInt(s[0]));
        } else {
            ss = "$" + s[0];
        }
        String ss2 = "";
        if (s.length == 1) {
            ss2=".00";
        } else {
            if (s[1].length() < 2) {
                s[1] += "00";
            }
            for (int i = 0; i < 2; i++) {
                ss2 += s[1].charAt(i);
            }
            ss2 = "." + ss2;
        }
        if (ss.contains("-")) {
            ss = "(" + ss.replace("-", "") + ss2 + ")";

        }else{
            ss=ss+ss2;
        }

        System.out.println(ss);
    }
}


import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import static java.lang.System.*;

public class uang {

    static BufferedReader br;

    public static void init() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public static String getString() {
        try {
            if (br == null) {
                init();
            }
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            if (br == null) {
                init();
            }
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            if (br == null) {
                init();
            }
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void main(String[] ar) {
        String s[] = getString().split("\\.");
        DecimalFormat dd = new DecimalFormat("$0,000");
        String ss = "";
        if (Math.abs(Long.parseLong(s[0])) > 999) {
            ss = dd.format(Long.parseLong(s[0]));
        } else {
            ss = "$" + s[0];
        }
        String ss2 = "";
        if (s.length == 1) {
            ss2=".00";
        } else {
            if (s[1].length() < 2) {
                s[1] += "00";
            }
            for (int i = 0; i < 2; i++) {
                ss2 += s[1].charAt(i);
            }
            ss2 = "." + ss2;
        }
        if (ss.contains("-")) {
            ss = "(" + ss.replace("-", "") + ss2 + ")";

        }else{
            ss=ss+ss2;
        }

        System.out.println(ss);
    }
}


import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import static java.lang.System.*;

public class uang {

    static BufferedReader br;

    public static void init() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public static String getString() {
        try {
            if (br == null) {
                init();
            }
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            if (br == null) {
                init();
            }
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            if (br == null) {
                init();
            }
            String temp[] = br.readLine().split(" ");
            Integer temp2[] = new Integer[temp.length];
            for (int i = 0; i < temp.length; i++) {
                temp2[i] = Integer.parseInt(temp[i]);
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static void main(String[] ar) {
        String s[] = getString().split("\\.");
        DecimalFormat dd = new DecimalFormat("$0,000");
        String ss = "";
        if (Integer.parseInt(s[0]) > 999) {
            ss = dd.format(Integer.parseInt(s[0]));
        } else {
            ss = "$" + s[0];
        }
        String ss2 = "";
        if (s.length == 1) {
            ss2=".00";
        } else {
            if (s[1].length() < 2) {
                s[1] += "00";
            }
            for (int i = 0; i < 2; i++) {
                ss2 += s[1].charAt(i);
            }
            ss2 = "." + ss2;
        }
        if (ss.contains("-")) {
            ss = "(" + ss.replace("-", "") + ss2 + ")";

        }else{
            ss=ss+ss2;
        }

        System.out.println(ss);
    }
}


import java.util.*;
public class HelpKingdomofFarFarAway2_143B {
    public static Scanner in= new Scanner(System.in);

    public static void main(String[] args) {
        String a = in.nextLine();
        String num = "0123456789";
        if(num.contains(a.charAt(0)+""))
            fN(a);
        else
            minus(a);
//      if (a.charAt(0) == '-')
    }
    public static void minus (String a){
        System.out.print("(");
        fN(a.substring(1));
        System.out.print(")");
    }
    public static void fN (String a){
        System.out.print("$");
        String[] aa = a.split("\\."); //"\\." == "."
        if (aa.length < 2)
            front(a);
        else
            front(aa[0]);
        System.out.print(".");
        if (aa.length <2)
            System.out.print("00");
        else
            back(aa[1]);
    }
    public static void front (String a){
        int n = a.length();
        for (int i =0; i<n%3; i++)
            System.out.print(a.charAt(i));
        a= a.substring(n%3);
        if (a.length()>0){
             n = a.length();
             for (int i = 0; i<n/3; i++) {
                 System.out.print(",");
                 for (int j =0; j<3; j++)
                     System.out.print(a.charAt(j));
                 a = a.substring(3);
             }
        }
    }
    public static void back (String a){
        if (a.length() >= 2){
             System.out.print(a.charAt(0));
             System.out.print(a.charAt(1));
        }
        else// (a.length() == 1){
        {   System.out.print(a.charAt(0));
            System.out.print("0");
        }
    }
}


import java.util.*;
public class HelpKingdomofFarFarAway2_143B {
    public static Scanner in= new Scanner(System.in);

    public static void main(String[] args) {
        String a = in.nextLine();
        String num = "0123456789";
        if(num.contains(a.charAt(0)+""))
            fN(a);
        else
            minus(a);
//      if (a.charAt(0) == '-')
    }
    public static void minus (String a){
        System.out.print("(");
        fN(a.substring(1));
        System.out.print(")");
    }
    public static void fN (String a){
        System.out.print("$");
        String[] aa = a.split("\\."); //"\\." == "."
        if (aa.length == 0)
            front(a);
        else
            front(aa[0]);
        System.out.print(".");
        if (aa.length == 0)
            System.out.print("00");
        else
            back(aa[1]);
    }
    public static void front (String a){
        int n = a.length();
        for (int i =0; i<n%3; i++)
            System.out.print(a.charAt(i));
        a= a.substring(n%3);
        if (a.length()>0){
             n = a.length();
             for (int i = 0; i<n/3; i++) {
                 System.out.print(",");
                 for (int j =0; j<3; j++)
                     System.out.print(a.charAt(j));
                 a = a.substring(3);
             }
        }
    }
    public static void back (String a){
        if (a.length() >= 2){
             System.out.print(a.charAt(0));
             System.out.print(a.charAt(1));
        }
        else// (a.length() == 1){
        {   System.out.print(a.charAt(0));
            System.out.print("0");
        }
    }
}


import java.util.*;
public class HelpKingdomofFarFarAway2_143B {
    public static Scanner in= new Scanner(System.in);

    public static void main(String[] args) {
        String a = in.nextLine();
        String num = "0123456789";
        if(num.contains(a.charAt(0)+""))
            fN(a);
        else
            minus(a);
//      if (a.charAt(0) == '-')
    }
    public static void minus (String a){
        System.out.print("(");
        fN(a.substring(1));
        System.out.print(")");
    }
    public static void fN (String a){
        System.out.print("$");
        String[] aa = a.split("\\."); //"\\." == "."
        if (aa.length < 2)
            front(a);
        else
            front(aa[0]);
        System.out.print(".");
        if (aa.length <2)
            System.out.print("00");
        else
            back(aa[1]);
    }
    public static void front (String a){
        int n = a.length();
        for (int i =0; i<n%3; i++)
            System.out.print(a.charAt(i));
        a= a.substring(n%3);
        if (a.length()>0){
            if (n%3 != 0)
                System.out.print(",");
             n = a.length();
             for (int i = 0; i<n/3; i++) {
                 for (int j =0; j<3; j++) {
                     System.out.print(a.charAt(j));
                     if (j ==2&& i!=n/3-1)
                         System.out.print(",");
                 }
                 a = a.substring(3);
             }
        }
    }
    public static void back (String a){
        if (a.length() >= 2){
             System.out.print(a.charAt(0));
             System.out.print(a.charAt(1));
        }
        else// (a.length() == 1){
        {   System.out.print(a.charAt(0));
            System.out.print("0");
        }
    }
}


import java.util.*;
public class HelpKingdomofFarFarAway2_143B {
    public static Scanner in= new Scanner(System.in);

    public static void main(String[] args) {
        String a = in.nextLine();
        String num = "0123456789";
        if(num.contains(a.charAt(0)+""))
            fN(a);
        else
            minus(a);
//      if (a.charAt(0) == '-')
    }
    public static void minus (String a){
        System.out.print("(");
        fN(a.substring(1));
        System.out.print(")");
    }
    public static void fN (String a){
        System.out.print("$");
        String[] aa = a.split("\\."); //"\\." == "."
        if (aa.length < 2)
            front(a);
        else
            front(aa[0]);
        System.out.print(".");
        if (aa.length <2)
            System.out.print("00");
        else
            back(aa[1]);
    }
    public static void front (String a){
        int n = a.length();
        for (int i =0; i<n%3; i++)
            System.out.print(a.charAt(i));
        a= a.substring(n%3);
        if (a.length()>0){
             n = a.length();
             for (int i = 0; i<n/3; i++) {
                 for (int j =0; j<3; j++)
                     System.out.print(a.charAt(j));
                 System.out.print(",");
                 a = a.substring(3);
             }
        }
    }
    public static void back (String a){
        if (a.length() >= 2){
             System.out.print(a.charAt(0));
             System.out.print(a.charAt(1));
        }
        else// (a.length() == 1){
        {   System.out.print(a.charAt(0));
            System.out.print("0");
        }
    }
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    val tokenizer = StringTokenizer(jin.readLine())
    val freq = IntArray(20)
    for (j in 1..n) {
        val k = tokenizer.nextToken().toInt()
        for (e in 0..19) {
            if (((k shr e) and 1) == 1) {
                freq[e]++
            }
        }
    }
    val after = LongArray(n)
    for (e in 0..19) {
        for (j in 0 until freq[e]) {
            after[j] += 1L shl e
        }
    }
    var answer = 0L
    for (k in after) {
        answer += k * k
    }
    println(answer)
}


import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()
	val array = f.readLine().split(" ").map{it.toLong()}

	val freq = IntArray(21)

	for(k in 0 until n){
		var i = array[k]
		var p = 0
		while(i > 0){
			if(i and 1L == 1L){
				freq[p]++
			}
			i = i shr 1
			p++
		}
	}

	val max = freq.max()!!

	var answer = 0L
	for(k in 1..max){
		var sum = 0L
		for(j in 0..20){
			if(freq[j] >= k) sum += 1L shl j
		}
		answer += sum*sum
	}

	println(answer)
}