import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

 public class Main{
	public static boolean debugging = true;

	public static IOMonster2 io;

	public static boolean writtingToFile = true;
	public static String outputURL = "output.txt";

	public static int students;
	public static int[] scores =  new int[2005], ratings;
	public static String result;

	public static void main(String[] args) throws IOException {
		io = new IOMonster2(writtingToFile, outputURL, false);

		result = "";
		students = io.nextInt();

		init();
		partSum();
		process();

		io.printLoad();
		io.endIO();
	}

	public static void init() throws IOException
	{
		ratings =  new int[students];

		for(int index = 0; index < students; index++)
		{
			ratings[index] = io.nextInt();
			scores[ratings[index]]++;
		}
	}

	public static void partSum()
	{
		for(int index = 1; index < scores.length; index++)
		{
			scores[index] += scores[index - 1];
		}
	}

	public static void process()
	{
		io.load(placementOf(ratings[0]) + "");

		for(int index = 1; index < ratings.length; index++)
		{
			io.load(" " + placementOf(ratings[index]));
		}
	}

	public static int placementOf(int rating)
	{
		return students - scores[rating] + 1;
	}
}

 class IOMonster2{
	public BufferedReader inB;
	public Scanner inS;

	public boolean usingScanner;

	public StringTokenizer st;
	public StringBuilder out;
	public String currentLine;

	public boolean writtingToFile;
	public FileWriter writer;

	public IOMonster2(boolean writtingToFile, String outputURL, boolean usingScanner) throws IOException
	{
		this.usingScanner = usingScanner;

		if(!usingScanner)
		{
			inB = new BufferedReader(new InputStreamReader(System.in));
		}
		else
		{
			inS = new Scanner(System.in);
		}

		out = new StringBuilder();

		if(!usingScanner)
		{
			currentLine = inB.readLine();
		}
		else
		{
			currentLine = inS.nextLine();
		}

		st = new StringTokenizer(currentLine, " ");

		this.writtingToFile = writtingToFile;

		if(writtingToFile)
		{
			writer = new FileWriter(new File(outputURL));
		}
	}

	public void endIO() throws IOException
	{
		if(writtingToFile)
		{
			writer.close();
		}

		if(!usingScanner)
		{
			inB.close();
		}
		else
		{
			inS.close();
		}
	}

	public boolean conditionalChecker(boolean isTrue) throws IOException
	{
		if(!usingScanner)
		{
			return isTrue == false;
		}
		else
		{
			return inS.hasNextLine();
		}
	}

	public String next() throws IOException
	{
		if(!usingScanner)
		{
			if(currentLine != null && st.hasMoreTokens())
			{
				return st.nextToken();
			}
			else
			{
				st = new StringTokenizer((currentLine = inB.readLine()), " ");

				return next();
			}
		}
		else
		{
			return inS.next();
		}
	}

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

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

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

	public float nextFloat() throws IOException
	{
		return Float.parseFloat(next());
	}

	public String nextLine() throws IOException
	{
		if(!usingScanner)
		{
			if(currentLine != null)
			{
				return st.nextToken("\n");
			}
			else
			{
				st = new StringTokenizer((currentLine) = inB.readLine(), " ");
				return nextLine();
			}
		}
		else
		{
			return inS.nextLine();
		}
	}

	public void load(String s)
	{
		out.append(s);
	}

	public StringBuilder getLoad()
	{
		return out;
	}

	public void print(String s)
	{
		System.out.print(s);
	}

	public void println(String s)
	{
		System.out.println(s);
	}

	public void print(StringBuilder sb)
	{
		System.out.print(sb);
	}

	public void println(StringBuilder sb)
	{
		System.out.println(sb);
	}

	public void printLoad()
	{
		System.out.print(out);
	}

	public void printlnLoad()
	{
		System.out.println(out);
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

 public class IOMonster2{
	public BufferedReader inB;
	public Scanner inS;

	public boolean usingScanner;

	public StringTokenizer st;
	public StringBuilder out;
	public String currentLine;

	public boolean writtingToFile;
	public FileWriter writer;

	public IOMonster2(boolean writtingToFile, String outputURL, boolean usingScanner) throws IOException
	{
		this.usingScanner = usingScanner;

		if(!usingScanner)
		{
			inB = new BufferedReader(new InputStreamReader(System.in));
		}
		else
		{
			inS = new Scanner(System.in);
		}

		out = new StringBuilder();

		if(!usingScanner)
		{
			currentLine = inB.readLine();
		}
		else
		{
			currentLine = inS.nextLine();
		}

		st = new StringTokenizer(currentLine, " ");

		this.writtingToFile = writtingToFile;

		if(writtingToFile)
		{
			writer = new FileWriter(new File(outputURL));
		}
	}

	public void endIO() throws IOException
	{
		if(writtingToFile)
		{
			writer.close();
		}

		if(!usingScanner)
		{
			inB.close();
		}
		else
		{
			inS.close();
		}
	}

	public boolean conditionalChecker(boolean isTrue) throws IOException
	{
		if(!usingScanner)
		{
			return isTrue == false;
		}
		else
		{
			return inS.hasNextLine();
		}
	}

	public String next() throws IOException
	{
		if(!usingScanner)
		{
			if(currentLine != null && st.hasMoreTokens())
			{
				return st.nextToken();
			}
			else
			{
				st = new StringTokenizer((currentLine = inB.readLine()), " ");

				return next();
			}
		}
		else
		{
			return inS.next();
		}
	}

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

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

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

	public float nextFloat() throws IOException
	{
		return Float.parseFloat(next());
	}

	public String nextLine() throws IOException
	{
		if(!usingScanner)
		{
			if(currentLine != null)
			{
				return st.nextToken("\n");
			}
			else
			{
				st = new StringTokenizer((currentLine) = inB.readLine(), " ");
				return nextLine();
			}
		}
		else
		{
			return inS.nextLine();
		}
	}

	public void load(String s)
	{
		out.append(s);
	}

	public StringBuilder getLoad()
	{
		return out;
	}

	public void print(String s)
	{
		System.out.print(s);
	}

	public void println(String s)
	{
		System.out.println(s);
	}

	public void print(StringBuilder sb)
	{
		System.out.print(sb);
	}

	public void println(StringBuilder sb)
	{
		System.out.println(sb);
	}

	public void printLoad()
	{
		System.out.print(out);
	}

	public void printlnLoad()
	{
		System.out.println(out);
	}
}

 public class Main{
	public static boolean debugging = true;

	public static IOMonster2 io;

	public static boolean writtingToFile = true;
	public static String outputURL = "output.txt";

	public static int students;
	public static int[] scores =  new int[2005], ratings;
	public static String result;

	public static void main(String[] args) throws IOException {
		io = new IOMonster2(writtingToFile, outputURL, false);

		result = "";
		students = io.nextInt();

		init();
		partSum();
		process();

		io.printLoad();
		io.endIO();
	}

	public static void init() throws IOException
	{
		ratings =  new int[students];

		for(int index = 0; index < students; index++)
		{
			ratings[index] = io.nextInt();
			scores[ratings[index]]++;
		}
	}

	public static void partSum()
	{
		for(int index = 1; index < scores.length; index++)
		{
			scores[index] += scores[index - 1];
		}
	}

	public static void process()
	{
		io.load(placementOf(ratings[0]) + "");

		for(int index = 1; index < ratings.length; index++)
		{
			io.load(" " + placementOf(ratings[index]));
		}
	}

	public static int placementOf(int rating)
	{
		return students - scores[rating] + 1;
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main{
	public static boolean debugging = true;

	public static IOMonster2 io;

	public static boolean writtingToFile = true;
	public static String outputURL = "output.txt";

	public static int students;
	public static int[] scores =  new int[2005], ratings;

	public static void main(String[] args) throws IOException {
		io = new IOMonster2(writtingToFile, outputURL, false);

		students = io.nextInt();

		init();
		partSum();
		process();

		io.printLoad();
		io.endIO();
	}

	public static void init() throws IOException
	{
		ratings =  new int[students];

		for(int index = 0; index < students; index++)
		{
			ratings[index] = io.nextInt();
			scores[ratings[index]]++;
		}
	}

	public static void partSum()
	{
		for(int index = 1; index < scores.length; index++)
		{
			scores[index] += scores[index - 1];
		}
	}

	public static void process()
	{
		io.load(placementOf(ratings[0]) + "");

		for(int index = 1; index < ratings.length; index++)
		{
			io.load(" " + placementOf(ratings[index]));
		}
	}

	public static int placementOf(int rating)
	{
		return students - scores[rating] + 1;
	}
}

class IOMonster2{
	public BufferedReader inB;
	public Scanner inS;

	public boolean usingScanner;

	public StringTokenizer st;
	public StringBuilder out;
	public String currentLine;

	public boolean writtingToFile;
	public FileWriter writer;

	public IOMonster2(boolean writtingToFile, String outputURL, boolean usingScanner) throws IOException
	{
		this.usingScanner = usingScanner;

		if(!usingScanner)
		{
			inB = new BufferedReader(new InputStreamReader(System.in));
		}
		else
		{
			inS = new Scanner(System.in);
		}

		out = new StringBuilder();

		if(!usingScanner)
		{
			currentLine = inB.readLine();
		}
		else
		{
			currentLine = inS.nextLine();
		}

		st = new StringTokenizer(currentLine, " ");

		this.writtingToFile = writtingToFile;

		if(writtingToFile)
		{
			writer = new FileWriter(new File(outputURL));
		}
	}

	public void endIO() throws IOException
	{
		if(writtingToFile)
		{
			writer.close();
		}

		if(!usingScanner)
		{
			inB.close();
		}
		else
		{
			inS.close();
		}
	}

	public boolean conditionalChecker(boolean isTrue) throws IOException
	{
		if(!usingScanner)
		{
			return isTrue == false;
		}
		else
		{
			return inS.hasNextLine();
		}
	}

	public String next() throws IOException
	{
		if(!usingScanner)
		{
			if(currentLine != null && st.hasMoreTokens())
			{
				return st.nextToken();
			}
			else
			{
				st = new StringTokenizer((currentLine = inB.readLine()), " ");

				return next();
			}
		}
		else
		{
			return inS.next();
		}
	}

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

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

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

	public float nextFloat() throws IOException
	{
		return Float.parseFloat(next());
	}

	public String nextLine() throws IOException
	{
		if(!usingScanner)
		{
			if(currentLine != null)
			{
				return st.nextToken("\n");
			}
			else
			{
				st = new StringTokenizer((currentLine) = inB.readLine(), " ");
				return nextLine();
			}
		}
		else
		{
			return inS.nextLine();
		}
	}

	public void load(String s)
	{
		out.append(s);
	}

	public StringBuilder getLoad()
	{
		return out;
	}

	public void print(String s)
	{
		System.out.print(s);
	}

	public void println(String s)
	{
		System.out.println(s);
	}

	public void print(StringBuilder sb)
	{
		System.out.print(sb);
	}

	public void println(StringBuilder sb)
	{
		System.out.println(sb);
	}

	public void printLoad()
	{
		System.out.print(out);
	}

	public void printlnLoad()
	{
		System.out.println(out);
	}
}


import java.util.Scanner;

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

	int n =sc.nextInt();

	int[] ratings = new int[n];

	for (int i = 0; i < n; i++) {
		ratings[i]=sc.nextInt();

	}

	for (int i = 0; i < n; i++) {
		int count=0;
		for (int j = 0;j < n;++j) {
			if(ratings[j]>ratings[i])
				count++;
		}
		System.out.print(1+count+" ");
	}
}
}


import java.util.Scanner;

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

	int n =sc.nextInt();

	int[] ratings = new int[n];

	for (int i = 0; i < n; i++) {
		ratings[i]=sc.nextInt();

	}

	for (int i = 0; i < n; i++) {
		int count=0;
		for (int j = 1; j <= n-1; j++) {
			if(ratings[j]>ratings[i])
				count++;
		}
		System.out.print(1+count+" ");
	}
}
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        //Student[] students = new Student[numStudents];
                System.out.println("Hi");

       /* for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

/*class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}*/


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        //Student[] students = new Student[numStudents];
                System.out.println("Hi");

       /* for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

/*class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}*/


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i+1, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.initPos,s2.initPos);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.finalPosition + " "); });
    }
}

class Student{
    public int initPos;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        initPos = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i+1, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.rating,s2.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];
                System.out.println("Hi");

       /* for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[students];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return s2.rating.compareTo(s1.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return s1.inputPosition.compareTo(s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i+1, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.rating,s2.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

private class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        //Student[] students = new Student[numStudents];
                System.out.println("Hi");

       /* for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

/*class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }*/
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i+1, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });

        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }

}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        System.out.println("Hi");

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

    class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i+1, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }

}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[students];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return s2.rating.compareTo(s1.rating);
            }
        }

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return s1.inputPosition.compareTo(s2.inputPosition);
            }
        }

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }

    class Student{
        public int inputPosition;
        public int rating;
        public int finalPosition;

        public Student(int in, int rating){
            inputPosition = in;
            this.rating = rating;
        }*/
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return s2.rating.compareTo(s1.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return s1.inputPosition.compareTo(s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        //Student[] students = new Student[numStudents];
                System.out.println("Hi");

       /* for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
  /*      int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });
        */

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i+1, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });
        */

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

  /*      Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });*/
    }

}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });

        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=1;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });
        System.out.println("HERE");
        int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i;
                lastRating = students[i].rating;
                lastRatingStudent = i;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }

}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Contest{
    public static void main(String args){
        Scanner scan = new Scanner(System.in);

        int numStudents = scan.nextInt();

        Student[] students = new Student[numStudents];

        for( int i=0;i<numStudents;i++){
            students[i] = new Student(i, scan.nextInt());
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s2.rating,s1.rating);
            }
        });

  /*      int lastRating = 0;
        int lastRatingStudent=-1;
        for(int i=0;i<numStudents;i++){
            if(students[i].rating == lastRating){
                students[i].finalPosition = lastRatingStudent;
            }else{
                students[i].finalPosition = i+1;
                lastRating = students[i].rating;
                lastRatingStudent = i+1;
            }
        }

        Arrays.sort(students, new Comparator<Student>(){
            public int compare(Student s1, Student s2){
                return Integer.compare(s1.inputPosition,s2.inputPosition);
            }
        });
        */

        Arrays.stream(students).forEach(s -> { System.out.print(s.rating + " "); });
    }
}

class Student{
    public int inputPosition;
    public int rating;
    public int finalPosition;

    public Student(int in, int rating){
        inputPosition = in;
        this.rating = rating;
    }
}


//https://codeforces.com/problemset/problem/551/A
//package codeforces;

import java.util.Scanner;

public class Problem551A {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		int[] ratingCount = new int[2002];
		int[] rating = new int[N];
		int maxRating = 0;
		for (int i = 0; i < N; i++) {
			rating[i] = scanner.nextInt();
			ratingCount[rating[i]]++;
			if(rating[i] >  maxRating)
				maxRating = rating[i];
		}
		scanner.close();
		for(int i = 0; i < N; i++) {
			int place = 1;
			for (int j = rating[i] + 1; j <= maxRating; j++)
				place += ratingCount[j];
			System.out.print(place + " ");
		}

	}

}


//package codeforces;

import java.util.Scanner;

public class Problem551A {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		int[] ratingCount = new int[2000];
		int[] rating = new int[N];
		int maxRating = 0;
		for (int i = 0; i < N; i++) {
			rating[i] = scanner.nextInt();
			ratingCount[rating[i]]++;
			if(rating[i] >  maxRating)
				maxRating = rating[i];
		}
		scanner.close();
		for(int i = 0; i < N; i++) {
			int place = 1;
			for (int j = rating[i] + 1; j <= maxRating; j++)
				place += ratingCount[j];
			System.out.print(place + " ");
		}

	}

}


import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class btp {
	//5
	//3 5 3 4 5
	//4 1 4 3 1
	//3 3 4 5 5
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[2000];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			b[a[i]]++;
		}
		for(int i=0;i<n;i++){
			int num=0;
			for(int j=a[i]+1;j<2000;j++){
				num+=b[j];
			}
			if(i!=n-1){
				System.out.print(num+1+" ");
			}
			else{
				System.out.println(num+1);
			}
		}

		sc.close();
	}

}


import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class btp {
	//5
	//3 5 3 4 5
	//4 1 4 3 1
	//3 3 4 5 5
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[2001];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			b[a[i]]++;
		}
		for(int i=0;i<n;i++){
			int num=0;
			for(int j=a[i]+1;j<2000;j++){
				num+=b[j];
			}
			if(i!=n-1){
				System.out.print(num+1+" ");
			}
			else{
				System.out.println(num+1);
			}
		}

		sc.close();
	}

}


import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class btp {
	//5
	//3 5 3 4 5
	//4 1 4 3 1
	//3 3 4 5 5
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[2001];

		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			b[a[i]]++;
		}
		for(int i=0;i<n;i++){
			int num=0;
			for(int j=a[i]+1;j<2001;j++){
				num+=b[j];
			}
			if(i!=n-1){
				System.out.print(num+1+" ");
			}
			else{
				System.out.println(num+1);
			}
		}

		sc.close();
	}

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package pkg551a.gukizandcontest;

import java.util.*;

/**
 *
 * @author King
 */
public class GukiZAndContest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        ArrayList<Integer> a = new ArrayList<>();
        ArrayList<Integer> t = new ArrayList<>();
        int[] temp = new int[2000];

        int n = in.nextInt();
        int k;
        for (int i = 0; i < n; i++) {
            k = in.nextInt();
            a.add(k);
            t.add(k);
        }
        Collections.sort(t);
        for (int i = 0; i < n; i++) {
            temp[a.get(i)]++;
        }
        k = 0;
        int b;
        for (int i = 0; i < 2000; i++) {
            if (temp[i] != 0) {
                b = temp[i];
                temp[i] = n - temp[i] - k + 1;
                k += b;
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.print(temp[a.get(i)] + " ");
        }
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package pkg551a.gukizandcontest;

import java.util.*;

/**
 *
 * @author King
 */
public class GukiZAndContest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        ArrayList<Integer> a = new ArrayList<>();
        ArrayList<Integer> t = new ArrayList<>();
        int[] temp = new int[2001];

        int n = in.nextInt();
        int k;
        for (int i = 0; i < n; i++) {
            k = in.nextInt();
            a.add(k);
            t.add(k);
        }
        Collections.sort(t);
        for (int i = 0; i < n; i++) {
            temp[a.get(i)]++;
        }
        k = 0;
        int b;
        for (int i = 0; i < 2001; i++) {
            if (temp[i] != 0) {
                b = temp[i];
                temp[i] = n - temp[i] - k + 1;
                k += b;
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.print(temp[a.get(i)] + " ");
        }
    }

}


//package Homework_2;

//http://codeforces.com/problemset/problem/551/A

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Solution1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        Integer[] a = new Integer[n];
        Integer[] b = new Integer[n];
        HashMap<Integer, Integer> rankMap = new HashMap<>();

        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            b[i] = a[i];
        }

        Arrays.sort(b, Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            if (!rankMap.containsKey(b[i])) {
                rankMap.put(b[i], i + 1);
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.print(rankMap.get(a[i]));

            if (i < n - 1) {
                System.out.print(" ");
            }
        }
    }
}


package Homework_2;

//http://codeforces.com/problemset/problem/551/A

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Solution1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        Integer[] a = new Integer[n];
        Integer[] b = new Integer[n];
        HashMap<Integer, Integer> rankMap = new HashMap<>();

        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            b[i] = a[i];
        }

        Arrays.sort(b, Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            if (!rankMap.containsKey(b[i])) {
                rankMap.put(b[i], i + 1);
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.print(rankMap.get(a[i]));

            if (i < n - 1) {
                System.out.print(" ");
            }
        }
    }
}


import java.util.*;
public class Main {

	static int[] A = { 3,2,1 };
	static int[] B = { 1, 1, 9, 1, 1, 1, 1 };
	static int[] C = { 4, 5, 14 };
	static int[] D = { 7, 6, 8, 9, 10, 5 };
	static int[] E = { 7, 20, 88 };
	static int[] F = { 16, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] G = { 15, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] H = { 6, 11, 12, 15, 22, 24, 30, 31, 32, 33, 34, 35, 40, 42, 44, 45, 47, 50, 53, 54, 57, 58, 63, 67,
			75, 77, 79, 81, 83, 88 };
	static int[] I = { 1 };
	static int height = 5;

//	public static void main(String[] args) {
//		int k = 3;
//
//		Scanner sc = new Scanner(System.in);
//
//		int n = sc.nextInt();
////		int a = sc.nextInt();
////		int b = sc.nextInt();
//		int[] A = new int[n];
//		for (int i = 0; i < n; i++) {
//			A[i] = sc.nextInt();
//		}
//
////		solution(A, a, b);
//
//		// findDistinct2(a, b);
//
//		// solution(B, 3, 4);
//		solution451(A);
//	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		ArrayList<Integer> a = new ArrayList<> ();
		ArrayList<Student> studentList = new ArrayList<> ();

		for (int i = 0; i < n; i++) {
			int temp = sc.nextInt();
			a.add(temp);
			Student student = new Student(i, temp);
			studentList.add(student);
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.rating > st2.rating) ? -1 : 1;
			}
		});

		int position = 0;
		int lastPosition = 0;
		int max = Integer.MAX_VALUE;
		for (Student student : studentList) {
			System.out.println("position " + student.index + " rating " + student.rating);
			position++;
			if (student.rating < max) {
				max = student.rating;
				student.position = position;
				lastPosition = position;
			} else if (student.rating == max) {
				student.position = lastPosition;
			}
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.index < st2.index) ? -1 : 1;
			}
		});

		for (Student student : studentList) {
			System.out.print(student.position + " ");
		}

	}
	static class Student {
		public int index;
		public int position;
		public int rating;
		public Student(int index, int rating) {
			this.index = index;
			this.rating = rating;
		}
	}
}


import java.util.*;
public class Main {

	static int[] A = { 3,2,1 };
	static int[] B = { 1, 1, 9, 1, 1, 1, 1 };
	static int[] C = { 4, 5, 14 };
	static int[] D = { 7, 6, 8, 9, 10, 5 };
	static int[] E = { 7, 20, 88 };
	static int[] F = { 16, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] G = { 15, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] H = { 6, 11, 12, 15, 22, 24, 30, 31, 32, 33, 34, 35, 40, 42, 44, 45, 47, 50, 53, 54, 57, 58, 63, 67,
			75, 77, 79, 81, 83, 88 };
	static int[] I = { 1 };
	static int height = 5;

//	public static void main(String[] args) {
//		int k = 3;
//
//		Scanner sc = new Scanner(System.in);
//
//		int n = sc.nextInt();
////		int a = sc.nextInt();
////		int b = sc.nextInt();
//		int[] A = new int[n];
//		for (int i = 0; i < n; i++) {
//			A[i] = sc.nextInt();
//		}
//
////		solution(A, a, b);
//
//		// findDistinct2(a, b);
//
//		// solution(B, 3, 4);
//		solution451(A);
//	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		ArrayList<Integer> a = new ArrayList<> ();
		ArrayList<Student> studentList = new ArrayList<> ();

		for (int i = 0; i < n; i++) {
			int temp = sc.nextInt();
			a.add(temp);
			Student student = new Student(i, temp);
			studentList.add(student);
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.rating > st2.rating) ? -1 : 1;
			}
		});

		int position = 0;
		int lastPosition = 0;
		int max = Integer.MAX_VALUE;
		for (Student student : studentList) {
			position++;
			if (student.rating < max) {
				max = student.rating;
				student.position = position;
				lastPosition = position;
			} else if (student.rating == max) {
				student.position = lastPosition;
			}
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.index < st2.index) ? -1 : 1;
			}
		});

		for (Student student : studentList) {
			System.out.print(student.position + " ");
		}

	}
	static class Student {
		public int index;
		public int position;
		public int rating;
		public Student(int index, int rating) {
			this.index = index;
			this.rating = rating;
		}
	}
}


import java.util.*;
public class Main {

	static int[] A = { 3,2,1 };
	static int[] B = { 1, 1, 9, 1, 1, 1, 1 };
	static int[] C = { 4, 5, 14 };
	static int[] D = { 7, 6, 8, 9, 10, 5 };
	static int[] E = { 7, 20, 88 };
	static int[] F = { 16, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] G = { 15, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] H = { 6, 11, 12, 15, 22, 24, 30, 31, 32, 33, 34, 35, 40, 42, 44, 45, 47, 50, 53, 54, 57, 58, 63, 67,
			75, 77, 79, 81, 83, 88 };
	static int[] I = { 1 };
	static int height = 5;

//	public static void main(String[] args) {
//		int k = 3;
//
//		Scanner sc = new Scanner(System.in);
//
//		int n = sc.nextInt();
////		int a = sc.nextInt();
////		int b = sc.nextInt();
//		int[] A = new int[n];
//		for (int i = 0; i < n; i++) {
//			A[i] = sc.nextInt();
//		}
//
////		solution(A, a, b);
//
//		// findDistinct2(a, b);
//
//		// solution(B, 3, 4);
//		solution451(A);
//	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		ArrayList<Integer> a = new ArrayList<> ();
		ArrayList<Student> studentList = new ArrayList<> ();

		for (int i = 0; i < n; i++) {
			int temp = sc.nextInt();
			a.add(temp);
			Student student = new Student(i, temp);
			studentList.add(student);
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.rating > st2.rating) ? -1 : 1;
			}
		});

		int position = 0;
		int lastPosition = 0;
		int max = Integer.MAX_VALUE;
		for (Student student : studentList) {
			System.out.println("position " + student.index + " rating " + student.rating);
			position++;
			if (student.rating < max) {
				max = student.rating;
				student.position = position;
				lastPosition = position;
			} else if (student.rating == max) {
				student.position = lastPosition;
			}
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.index < st2.index) ? -1 : 1;
			}
		});

		for (Student student : studentList) {
			System.out.println("position " + student.index + " position " + student.position);
		}

	}
	static class Student {
		public int index;
		public int position;
		public int rating;
		public Student(int index, int rating) {
			this.index = index;
			this.rating = rating;
		}
	}
}


import java.util.*;
public class Main {

	static int[] A = { 3,2,1 };
	static int[] B = { 1, 1, 9, 1, 1, 1, 1 };
	static int[] C = { 4, 5, 14 };
	static int[] D = { 7, 6, 8, 9, 10, 5 };
	static int[] E = { 7, 20, 88 };
	static int[] F = { 16, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] G = { 15, 20, 30, 40, 50, 60, 70, 80, 90 };
	static int[] H = { 6, 11, 12, 15, 22, 24, 30, 31, 32, 33, 34, 35, 40, 42, 44, 45, 47, 50, 53, 54, 57, 58, 63, 67,
			75, 77, 79, 81, 83, 88 };
	static int[] I = { 1 };
	static int height = 5;

//	public static void main(String[] args) {
//		int k = 3;
//
//		Scanner sc = new Scanner(System.in);
//
//		int n = sc.nextInt();
////		int a = sc.nextInt();
////		int b = sc.nextInt();
//		int[] A = new int[n];
//		for (int i = 0; i < n; i++) {
//			A[i] = sc.nextInt();
//		}
//
////		solution(A, a, b);
//
//		// findDistinct2(a, b);
//
//		// solution(B, 3, 4);
//		solution451(A);
//	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		ArrayList<Integer> a = new ArrayList<> ();
		ArrayList<Student> studentList = new ArrayList<> ();

		for (int i = 0; i < n; i++) {
			int temp = sc.nextInt();
			a.add(temp);
			Student student = new Student(i, temp);
			studentList.add(student);
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.rating > st2.rating) ? -1 : 1;
			}
		});

		int position = 0;
		int lastPosition = 0;
		int max = Integer.MAX_VALUE;
		for (Student student : studentList) {
// 			System.out.println("position " + student.index + " rating " + student.rating);
			position++;
			if (student.rating < max) {
				max = student.rating;
				student.position = position;
				lastPosition = position;
			} else if (student.rating == max) {
				student.position = lastPosition;
			}
		}

		Collections.sort(studentList, new Comparator<Student>() {
			@Override
			public int compare(Student st1, Student st2) {
				return (st1.index < st2.index) ? -1 : 1;
			}
		});

		for (Student student : studentList) {
			System.out.println("position " + student.index + " position " + student.position);
		}

	}
	static class Student {
		public int index;
		public int position;
		public int rating;
		public Student(int index, int rating) {
			this.index = index;
			this.rating = rating;
		}
	}
}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;

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

	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int[] a = sc.readIntArray(n);
		int[] res = new int[n];
		int[] ac = a.clone();
		sc.shuffleIntArray(ac);
		Arrays.sort(ac);
		int cur = 1;
		int count = 0;
		while (cur<=n) {
			for (int i = 0; i < n; i++) {
				if (a[i] == ac[n-cur]) {
					res[i] = cur;
					count++;
				}
			}
			cur+=count;
			count = 0;
		}
		sc.outputIntArray(out, res);
		out.close();
	}
}

class FastScanner {
	public BufferedReader br;
	public StringTokenizer st;

	public FastScanner(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public boolean hasMoreTokens() {
		while (st == null || !st.hasMoreTokens()) {
			String line = null;
			try {
				line = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (line == null)
				return false;
			st = new StringTokenizer(line);
		}
		return true;
	}

	public String next() {
		if (!hasMoreTokens())
			return null;
		return st.nextToken();
	}

	public char nextChar(){
		try {
			return (char) br.read();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return 0;
	}
	public String nextLine(){
		try {
			return br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}

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

	//读一个int类型的数组
	public int[] readIntArray(int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = nextInt();
		}
		return array;
	}

	//读一个long数组
	public long[] readLongArray(int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = nextLong();
		}
		return array;
	}

	//读一个字符串数组
	public String[] readStringArray(int n) {
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = next();
		}
		return a;
	}

	//打乱一个数组，便于排序
	public void shuffleIntArray(int[] a) {
		Random rand = new Random();
		for (int i = 0; i < a.length; i++) {
			int x = rand.nextInt(i + 1); // 0~i
			int t = a[i];
			a[i] = a[x];
			a[x] = t;
		}
	}

	// 只适合比较小的数，太大的数会越界
	public long factorial(long n) {
		if (n == 0)
			return 1L;
		long res = 1;
		for (long i = 2; i <= n; i++) {
			res *= i;
		}
		return res;
	}

	// 只适合比较小的数，太大的数会越界
	public long combination(long mom, long son) {
		return factorial(mom) / (factorial(son) * factorial(mom - son));
	}

	//求最小公倍数
	public long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	//求最大公约数
	public long lcm(long a, long b) {
		return a * b / (gcd(a, b));
	}

	//格式化double类型的数
	public String format(String pattern, double d) {
		DecimalFormat df = new DecimalFormat(pattern);
		return df.format(d);
	}

	//判断一个数是否是2的指数
	public boolean isPowerOfTwo(long v) {
		return (v & (v - 1)) == 0;
	}

	public void outputIntArray(PrintWriter out, int[] a){
		for(int i = 0;i<a.length-1;i++)
			out.print(a[i] + " ");
		out.println(a[a.length-1]);
	}
}


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;

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

	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int[] a = sc.readIntArray(n);
		int[] res = new int[n];
		int cur = 1;
		int count = 0;
		int max = n;
		while (cur<=n) {
			for (int i = 0; i < n; i++) {
				if (a[i] == max) {
					res[i] = cur;
					count++;
				}
			}
			max--;
			cur+=count;
			count = 0;
		}
		sc.outputIntArray(out, res);
		out.close();
	}
}
class FastScanner {
	public BufferedReader br;
	public StringTokenizer st;

	public FastScanner(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public boolean hasMoreTokens() {
		while (st == null || !st.hasMoreTokens()) {
			String line = null;
			try {
				line = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (line == null)
				return false;
			st = new StringTokenizer(line);
		}
		return true;
	}

	public String next() {
		if (!hasMoreTokens())
			return null;
		return st.nextToken();
	}

	public char nextChar(){
		try {
			return (char) br.read();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return 0;
	}
	public String nextLine(){
		try {
			return br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}

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

	//读一个int类型的数组
	public int[] readIntArray(int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = nextInt();
		}
		return array;
	}

	//读一个long数组
	public long[] readLongArray(int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = nextLong();
		}
		return array;
	}

	//读一个字符串数组
	public String[] readStringArray(int n) {
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = next();
		}
		return a;
	}

	//打乱一个数组，便于排序
	public void shuffleIntArray(int[] a) {
		Random rand = new Random();
		for (int i = 0; i < a.length; i++) {
			int x = rand.nextInt(i + 1); // 0~i
			int t = a[i];
			a[i] = a[x];
			a[x] = t;
		}
	}

	// 只适合比较小的数，太大的数会越界
	public long factorial(long n) {
		if (n == 0)
			return 1L;
		long res = 1;
		for (long i = 2; i <= n; i++) {
			res *= i;
		}
		return res;
	}

	// 只适合比较小的数，太大的数会越界
	public long combination(long mom, long son) {
		return factorial(mom) / (factorial(son) * factorial(mom - son));
	}

	//求最小公倍数
	public long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	//求最大公约数
	public long lcm(long a, long b) {
		return a * b / (gcd(a, b));
	}

	//格式化double类型的数
	public String format(String pattern, double d) {
		DecimalFormat df = new DecimalFormat(pattern);
		return df.format(d);
	}

	//判断一个数是否是2的指数
	public boolean isPowerOfTwo(long v) {
		return (v & (v - 1)) == 0;
	}

	public void outputIntArray(PrintWriter out, int[] a){
		for(int i = 0;i<a.length-1;i++)
			out.print(a[i] + " ");
		out.println(a[a.length-1]);
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class CodeForces_551A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		try
		{
			int n = scan.nextInt();
			int[] arr = new int[n];
			int[] arrS = new int[n];
			int[] arrM = new int[2000+1];
			for (int i=0; i<n; i++) arr[i] = arrS[i] = scan.nextInt();
			Arrays.sort(arrS);
			int cont=0, ant=-1;
			for (int i=n-1; i>=0; i--)
			{
				if (arrS[i] != ant)
				{
					cont = n-1 - i;
					arrM[arrS[i]] = cont;
					ant = arrS[i];
				}
			}
			for (int i=0; i<n; i++) System.out.print(1+arrM[arr[i]]+" ");
		}
		catch (Exception e) { e.printStackTrace(); }
		finally { scan.close(); }
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class CodeForces_551A {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		try
		{
			int n = scan.nextInt();
			int[] arr = new int[n];
			int[] arrS = new int[n];
			int[] arrM = new int[n+1];
			for (int i=0; i<n; i++) arr[i] = arrS[i] = scan.nextInt();
			Arrays.sort(arrS);
			int cont=0, ant=-1;
			for (int i=n-1; i>=0; i--)
			{
				if (arrS[i] != ant)
				{
					cont = n-1 - i;
					arrM[arrS[i]] = cont;
					ant = arrS[i];
				}
			}
			for (int i=0; i<n; i++) System.out.print(1+arrM[arr[i]]+" ");
		}
		catch (Exception e) {  }
		finally { scan.close(); }
	}
}


import java.util.Arrays;
import java.util.Scanner;
public class Ranks {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		// Number of students
		int n = s.nextInt();
		// Create an array of n elements representing the ratings of n students
		int[] ratings = new int[n];
		// Create an array of n elements representing the rankings of n students
		int[] ranks = new int[n];
		for (int i=0; i<n; i++) {
			ratings[i] = s.nextInt();
		}
		// Sort the ratings
		int[] drone = ratings;
		Arrays.sort(drone);
		int nextRank = 1;
		ranks[n-1] = 1;
		for (int i=n-1; i>0; i--) {
			if (drone[i-1] == drone[i]) {
				ranks[i-1] = ranks[i];
				nextRank = n-2;
 			} else {
 				ranks[i-1] = nextRank;
 			}
		}
		for (int i=0; i<n; i++) {
			System.out.print(ranks[Arrays.binarySearch(drone, ratings[i])]+" ");
		}
		s.close();
	}
}


import java.util.Arrays;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		// Number of students
		int n = s.nextInt();
		// Create an array of n elements representing the ratings of n students
		int[] ratings = new int[n];
		// Create an array of n elements representing the rankings of n students
		int[] ranks = new int[n];
		// Array to sort the ratings
		int[] drone = new int[n];
		for (int i=0; i<n; i++) {
			int temp = s.nextInt();
			ratings[i] = temp;
			drone[i] = temp;
		}
		Arrays.sort(drone);
		// Turn into descending
		int[] descend = new int[n];
		int j = 0;
		// List to check existence
		ArrayList<Integer> check = new ArrayList<Integer>();
		for (int i=n-1; i>=0; i--) {
			descend[j] = drone[i];
			j++;
		}
		// Assign ranks
		for (int i=0; i<n; i++) {
			if (!check.contains(descend[i])) {
				ranks[i] = i+1;
				check.add(descend[i]);
			} else {
				ranks[i] = ranks[i-1];
			}
		}
		// Turn back into ascending
		int [] reversed = new int[n];
		j = 0;
		for (int i=n-1; i>=0; i--) {
			reversed[j] = ranks[i];
			j++;
		}
		// Print results
		for (int i=0; i<n; i++) {
			System.out.print(reversed[Arrays.binarySearch(drone, ratings[i])]+" ");
		}
		s.close();
	}
}


import java.util.Arrays;
import java.util.Scanner;
public class Ranks {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		// Number of students
		int n = s.nextInt();
		// Create an array of n elements representing the ratings of n students
		int[] ratings = new int[n];
		// Create an array of n elements representing the rankings of n students
		int[] ranks = new int[n];
		for (int i=0; i<n; i++) {
			ratings[i] = s.nextInt();
		}
		// Sort the ratings
		int[] drone = ratings;
		Arrays.sort(drone);
		int nextRank = 1;
		ranks[n-1] = 1;
		for (int i=n-1; i>0; i++) {
			if (drone[i-1] == drone[i]) {
				ranks[i-1] = ranks[i];
				nextRank = n-2;
 			} else {
 				ranks[i-1] = nextRank;
 			}
		}
		for (int i=0; i<n; i++) {
			System.out.print(ranks[Arrays.binarySearch(drone, ratings[i])]+" ");
		}
		s.close();
	}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Porya
 */
import java.util.*;
public class GukiZAndContest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);

        int n=sc.nextInt();
        int a[]=new int[2000];
        int b[]=new int[n];
        int c[]=new int[n];
        int t=1;
        for (int i = 0; i < n; i++) {
            b[i]=sc.nextInt();
            a[b[i]-1]++;

        }
        if(n!=1)
        {
            for (int j = 0; j < n; j++) {
                if(a[n-j-1]!=0)
                {
                    for (int i = 0; i < n; i++) {
                        if(b[i]==n-j)
                        {
                            c[i]=t;
                        }
                    }
                    t+=a[n-j-1];
                }
            }
            System.out.print(c[0]+"");
            for (int i = 1; i < n; i++) {
                System.out.print(" "+c[i]);
            }
        }
        else if(n==1)
            System.out.println("1");

    }

}


/*********************"ANJAN AGARWALA"************************
***************************@anjn98****************************/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define IO 				ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 			v.begin(),v.end()
#define PR(a) 			cout<<"("<<a<<")";
#define ED 				cout<<'\n';
#define endl 			'\n'
#define loop(j,a,n) 	for(int j=a;j<=n;j++)
#define loop1(j,a,n) 	for(int j=a;j>=n;j--)
#define fr1(j,n) 		for(int j=0;j<n;j++)
#define fr(n) 			for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define PB 				push_back
#define MP 				make_pair
#define pii 			pair<int,int>
#define pll 			pair<long long int,long long int>
#define F 				first
#define S 				second
#define binf 			2000000000000000001
#define mod 			1000000007

const int  M=1,N=1e3+9;

ll arr[N][N];
int32_t main()
{
    ll n,m,k,p;
    cin>>n>>m>>k>>p;
    priority_queue<int> pqr,pqc;

    fr(n)fr1(j,m) cin>>arr[i][j];

    fr(n)
    {
        ll ans=0;
        fr1(j,m)ans+=arr[i][j];
        pqc.push(ans);
    }

    fr(m)
    {
        ll ans=0;
        fr1(j,n)ans+=arr[j][i];
        pqr.push(ans);
    }
    ll ans=0;ll r=0,c=0;;
    for(int i=0;i<k;i++)
    {
        //PR(pqc.top()) PR(pqr.top())ED
        if(pqc.top()-c > pqr.top()-r)
        {
            ans+=(pqc.top()-c);
            ll bb=(pqc.top());
            pqc.pop();
            bb-=p*m;
            pqc.push(bb);
            r+=p;
            //PR(ans)
            continue;
        }
        ans+=(pqr.top()-r);
        ll bb=(pqr.top());
        bb-=p*n;
        pqr.pop();
        pqr.push(bb);
        c+=p;
        //cout<<ans<<endl;

    }
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v))
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

signed main()
{
	fastio(0);
	int n,m,k,p;
	cin>>n>>m>>k>>p;
	int a[n][m],dpa[k+1],dpb[k+1],sum=0;
	init(dpa,0);
	init(dpb,0);
	multiset<int, greater<int>> A,B;
	loop(i,0,n) loop(j,0,m) cin>>a[i][j];

	loop(i,0,n)
	{
		sum = 0;
		loop(j,0,m) sum += a[i][j];
		A.insert(sum);
	}

	loop(j,0,m)
	{
		sum = 0;
		loop(i,0,n) sum += a[i][j];
		B.insert(sum);
	}

	loop(i,1,k+1)
	{
		int x = *A.begin();
		A.erase(A.begin());
		A.insert(x-m*p);
		dpa[i] = dpa[i-1] + x;
		// bug(size(A));
	}

	loop(i,1,k+1)
	{
		int x = *B.begin();
		B.erase(B.begin());
		B.insert(x-n*p);
		dpb[i] = dpb[i-1] + x;
		// bug(size(B));
	}
	int ans = 0;
	loop(i,0,k+1)
		ans = max(ans, dpa[i] + dpb[k-i] - i*(k-i)*p);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v))
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

signed main()
{
	fastio(0);
	int n,m,k,p;
	cin>>n>>m>>k>>p;
	int a[n][m],dpa[k+1],dpb[k+1],sum=0;
	init(dpa,0);
	init(dpb,0);
	multiset<int, greater<int>> A,B;
	loop(i,0,n) loop(j,0,m) cin>>a[i][j];

	loop(i,0,n)
	{
		sum = 0;
		loop(j,0,m) sum += a[i][j];
		A.insert(sum);
	}

	loop(j,0,m)
	{
		sum = 0;
		loop(i,0,n) sum += a[i][j];
		B.insert(sum);
	}

	loop(i,1,k+1)
	{
		int x = *A.begin();
		A.erase(A.begin());
		A.insert(x-m*p);
		dpa[i] = dpa[i-1] + x;
	}

	loop(i,1,k+1)
	{
		int x = *B.begin();
		B.erase(B.begin());
		B.insert(x-n*p);
		dpb[i] = dpb[i-1] + x;
	}
	int ans = -inf;
	loop(i,0,k+1)
		ans = max(ans, dpa[i] + dpb[k-i] - i*(k-i)*p);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v))
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

signed main()
{
	fastio(0);
	int n,m,k,p;
	cin>>n>>m>>k>>p;
	int a[n][m],dpa[k+1],dpb[k+1],sum=0;
	init(dpa,0);
	init(dpb,0);
	multiset<int, greater<int>> A,B;
	loop(i,0,n) loop(j,0,m) cin>>a[i][j];

	loop(i,0,n)
	{
		sum = 0;
		loop(j,0,m) sum += a[i][j];
		A.insert(sum);
	}

	loop(j,0,m)
	{
		sum = 0;
		loop(i,0,n) sum += a[i][j];
		B.insert(sum);
	}

	loop(i,1,k+1)
	{
		int x = *A.begin();
		A.erase(A.begin());
		A.insert(x-m*p);
		dpa[i] = dpa[i-1] + x;
	}

	loop(i,1,k+1)
	{
		int x = *B.begin();
		B.erase(B.begin());
		B.insert(x-n*p);
		dpb[i] = dpb[i-1] + x;
	}
	int ans = -1000000000000000001;
	loop(i,0,k+1)
		ans = max(ans, dpa[i] + dpb[k-i] - i*(k-i)*p);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v))
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

signed main()
{
	fastio(0);
	int n,m,k,p;
	cin>>n>>m>>k>>p;
	int a[n][m],dpa[k+1],dpb[k+1],sum=0;
	init(dpa,0);
	init(dpb,0);
	multiset<int, greater<int>> A,B;
	loop(i,0,n) loop(j,0,m) cin>>a[i][j];

	loop(i,0,n)
	{
		sum = 0;
		loop(j,0,m) sum += a[i][j];
		A.insert(sum);
	}

	loop(j,0,m)
	{
		sum = 0;
		loop(i,0,n) sum += a[i][j];
		B.insert(sum);
	}

	loop(i,1,k+1)
	{
		int x = *A.begin();
		A.insert(x-m*p);
		A.erase(x);
		dpa[i] = dpa[i-1] + x;
	}

	loop(i,1,k+1)
	{
		int x = *B.begin();
		B.insert(x-n*p);
		B.erase(x);
		dpb[i] = dpb[i-1] + x;
	}
	int ans = 0;
	loop(i,0,k+1)
		ans = max(ans, dpa[i] + dpb[k-i] - i*(k-i)*p);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v))
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

signed main()
{
	fastio(0);
	int n,m,k,p;
	cin>>n>>m>>k>>p;
	int a[n][m],dpa[k+1],dpb[k+1],sum=0;
	init(dpa,0);
	init(dpb,0);
	multiset<int, greater<int>> A,B;
	loop(i,0,n) loop(j,0,m) cin>>a[i][j];
	loop(i,0,n)
	{
		sum = 0;
		loop(j,0,m) sum += a[i][j];
		A.insert(sum);
	}

	loop(j,0,m)
	{
		sum = 0;
		loop(i,0,n) sum += a[i][j];
		B.insert(sum);
	}

	loop(i,1,k+1)
	{
		int x = *A.begin();
		A.erase(A.begin());
		A.insert(x-n*p);
		if(i==0) dpa[i] = x;
		else dpa[i] = dpa[i-1] + x;
	}

	loop(i,1,k+1)
	{
		int x = *B.begin();
		B.erase(B.begin());
		B.insert(x-m*p);
		if(i==0) dpb[i] = x;
		else dpb[i] = dpb[i-1] + x;
	}
	int ans = 0;
	loop(i,0,k+1)
		ans = max(ans, dpa[i] + dpb[k-i] - i*(k-i)*p);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v))
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

signed main()
{
	fastio(0);
	int n,m,k,p;
	cin>>n>>m>>k>>p;
	int a[n][m],dpa[k+1],dpb[k+1],sum=0;
	init(dpa,0);
	init(dpb,0);
	multiset<int, greater<int>> A,B;
	loop(i,0,n) loop(j,0,m) cin>>a[i][j];

	loop(i,0,n)
	{
		sum = 0;
		loop(j,0,m) sum += a[i][j];
		A.insert(sum);
	}

	loop(j,0,m)
	{
		sum = 0;
		loop(i,0,n) sum += a[i][j];
		B.insert(sum);
	}

	loop(i,1,k+1)
	{
		int x = *A.begin();
		A.erase(x);
		A.insert(x-m*p);
		dpa[i] = dpa[i-1] + x;
	}

	loop(i,1,k+1)
	{
		int x = *B.begin();
		B.erase(x);
		B.insert(x-n*p);
		dpb[i] = dpb[i-1] + x;
	}
	int ans = 0;
	loop(i,0,k+1)
		ans = max(ans, dpa[i] + dpb[k-i] - i*(k-i)*p);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v))
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

signed main()
{
	fastio(0);
	int n,m,k,p;
	cin>>n>>m>>k>>p;
	int a[n][m],dpa[k+1],dpb[k+1],sum=0;
	init(dpa,0);
	init(dpb,0);
	vector<int> A,B;
	loop(i,0,n) loop(j,0,m) cin>>a[i][j];
	loop(i,0,n)
	{
		sum = 0;
		loop(j,0,m) sum += a[i][j];
		A.pb(sum);
	}

	loop(j,0,m)
	{
		sum = 0;
		loop(i,0,n) sum += a[i][j];
		B.pb(sum);
	}

	make_heap(all(A));
	make_heap(all(B));

	loop(i,1,k+1)
	{
		int x = A[0];
		A.pb(x-n*p);
		pop_heap(all(A));
		A.popb();
		if(i==0) dpa[i] = x;
		else dpa[i] = dpa[i-1] + x;
	}

	loop(i,1,k+1)
	{
		int x = B[0];
		B.pb(x-m*p);
		pop_heap(all(B));
		B.popb();
		if(i==0) dpb[i] = x;
		else dpb[i] = dpb[i-1] + x;
	}
	int ans = 0;
	loop(i,0,k+1)
		ans = max(ans, dpa[i] + dpb[k-i] - i*(k-i)*p);
	cout<<ans<<endl;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, k, p, row[1001], col[1001], ans = -inf, a[1001], b[1001];
multiset <int> r, c;

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	cin >> n >> m >> k >> p;
	for(int i = 1; i <= n; i ++)
		for (int j = 1, x; j <= m; j ++) {
			cin >> x;
			row[i] += x, col[j] += x;
		}
	for (int i = 1; i <= n; i ++) r.in (row[i]);
	for (int i = 1; i <= m; i ++) c.in (col[i]);
	for (int i = 1; i <= k; i ++) {
		int cur = *r.rbegin ();
		r.erase (r.find (cur));
		a[i] = a[i - 1] + cur;
		r.in (cur - m * p);
	}
	for (int i = 1; i <= k; i ++) {
		int cur = *c.rbegin ();
		c.erase (c.find (cur));
		b[i] = b[i - 1] + cur;
		c.in (cur - n * p);
	}
	for (int i = 0; i <= k; i ++) {
		int val = a[i] + b[k - i] - i * (k - i) * p;
		ans = max (ans, val);
	}
	cout << ans;
}

main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)1e6 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, k, p, row[1001], col[1001], ans = -inf, a[N], b[N];
multiset <int> r, c;

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	cin >> n >> m >> k >> p;
	for(int i = 1; i <= n; i ++)
		for (int j = 1, x; j <= m; j ++) {
			cin >> x;
			row[i] += x, col[j] += x;
		}
	for (int i = 1; i <= n; i ++) r.in (row[i]);
	for (int i = 1; i <= m; i ++) c.in (col[i]);
	for (int i = 1; i <= k; i ++) {
		int cur = *r.rbegin ();
		r.erase (r.find (cur));
		a[i] = a[i - 1] + cur;
		r.in (cur - m * p);
	}
	for (int i = 1; i <= k; i ++) {
		int cur = *c.rbegin ();
		c.erase (c.find (cur));
		b[i] = b[i - 1] + cur;
		c.in (cur - n * p);
	}
	for (int i = 0; i <= k; i ++) {
		int val = a[i] + b[k - i] - i * (k - i) * p;
		ans = max (ans, val);
	}
	cout << ans;
}

main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}