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

/**
 * @author abashkin
 */
public class YaQC implements Runnable {

    private static class Pair implements Comparable<Pair> {
        int a,b;

        boolean first;

        private Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair o) {
            if (a != o.a) return a - o.a;
            return b - o.b;
        }
    }

    public static void main(String[] args) {
        new Thread(new YaQC()).start();
    }

    public void run() {
        try{
            br = new BufferedReader(new InputStreamReader(System.in));
            pw = new PrintWriter(new OutputStreamWriter(System.out));
            solve();
            pw.close();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    private void solve() throws Exception {
        int n = nextInt();
        Pair a[] = new Pair[n];
        int n1 = nextInt();
        int n2 = nextInt();
        if (n1 == n2) {
            for (int i = 0; i < n1; i++) pw.print("1 ");
            for (int i = 0; i < n2; i++) pw.print("2 ");
        }
        for (int i = 0; i < n; i++) a[i] = new Pair(nextInt(), i);
        Arrays.sort(a);
        if (n2 - n1 > 0) {

            for (int i = n - 1, j = 0; j < n1; j++, i--) a[i].first = true;
            for (int i = 0; i < n2; i++) a[i].first = false;
        }
        else {
            for (int i = n - 1, j = 0; j < n2; j++, i--) a[i].first = false;
            for (int i = 0; i < n1; i++) a[i].first = true;

        }
        Arrays.sort(a, new Comparator<Pair>() {
            public int compare(Pair o1, Pair o2) {
                return o1.b - o2.b;
            }
        });

        for (int i = 0; i < n; i++) {
            if (a[i].first)
                pw.print("1 ");
            else pw.print("2 ");
        }
    }

    private BufferedReader br;
    private PrintWriter pw;
    private StringTokenizer tok;

    private String next() throws Exception {
        while (tok == null || !tok.hasMoreElements()) tok = new StringTokenizer(br.readLine());
        return tok.nextToken();
    }

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

}


import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Solution {
    private static int a;
    private static int b;

    static class Mark implements Comparable<Mark> {
        public int m;
        public int index;

        public Mark(int m, int i) {
            this.m = m;
            this.index = i;
        }

        public int compareTo(Mark m) {
            if (this.m != m.m)
                return this.m - m.m;
            else if (a >= b)
                return this.index - m.index;
            else
                return m.index - this.index;
        }

    }

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

        int n = in.nextInt();
        a = in.nextInt();
        b = in.nextInt();
        Mark[] arr = new Mark[n];

        for (int i = 0; i < n; i++) {
            Mark m = new Mark(in.nextInt(), i + 1);
            arr[i] = m;
        }

        Arrays.sort(arr);

        char sub1 = 1;
        char sub2 = 2;

        if (a == b) {
            for (int i = 0; i < a; i++)
                out.print("1 ");
            for (int i = 0; i < b; i++)
                out.print("2 ");
        } else {

            if (b > a) {
                int tmp = a;
                a = b;
                b = tmp;
                sub1 = 2;
                sub2 = 1;
            }

            int i = 0;
            int[] ans = new int[n];
            while (a > 0) {
                ans[arr[i].index - 1] = sub1;
                i++;
                a--;
            }

            while (b > 0) {
                ans[arr[i].index - 1] = sub2;
                i++;
                b--;
            }

            for (int j = 0; j < ans.length; j++) {
                out.print(ans[j] + " ");
            }
        }

        out.close();
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.lang.Double.*;
import static java.math.BigInteger.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable {

	private long start;

	private void solve() throws IOException {
//      start = System.currentTimeMillis();
		init();
		readData();
		processing();
	}

	private void processing() {
		int[] c = new int[6];
		fill(c, 0);
		for (int i = 0; i < n; ++i) {
			++c[marks[i]];
		}
		int[] take = new int[6];
		fill(take, 0);
		if (n > 2*a) {
			int r = a;
			for (int i = 5; i >= 1; --i) {
				if (c[i] <= r) {
					take[i] = c[i];
					r -= c[i];
					if (r == 0) {
						break;
					}
				}
				else {
					take[i] = r;
					r = 0;
					break;
				}
			}
			for (int i = 0; i < n; ++i) {
				if (take[marks[i]] > 0) {
					--take[marks[i]];
					print("1 ");
				}
				else {
					print("2 ");
				}
			}
		}
		else if (n < 2*a) {
			int r = a;
			for (int i = 1; i <= 5; ++i) {
				if (c[i] <= r) {
					take[i] = c[i];
					r -= c[i];
					if (r == 0) {
						break;
					}
				}
				else {
					take[i] = r;
					r = 0;
					break;
				}
			}
			for (int i = 0; i < n; ++i) {
				if (take[marks[i]] > 0) {
					--take[marks[i]];
					print("1 ");
				}
				else {
					print("2 ");
				}
			}
		}
		else {
			for (int i = 0; i < a; ++i) {
				print("1 ");
			}
			for (int i = 0; i < a; ++i) {
				print("2 ");
			}
		}
	}

	private void init() {

	}

	private void readData() throws IOException {
		n = nextInt();
		a = nextInt();
		b = nextInt();
		marks = new int[n];
		for (int i = 0; i < n; ++i) {
			marks[i] = nextInt();
		}
	}

	private int n;
	private int a;
	private int b;
	private int[] marks;

	private static final int INF = 1000000001;

	public static void main(String[] args) throws InterruptedException {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().run();
			}
		}, "1", 1 << 26).start();
	}

	// @Override
	public void run() {
		try {
			boolean onlineJudge = System.getProperty("ONLINE_JUDGE") != null;
			reader = onlineJudge ? new BufferedReader(new InputStreamReader(
					System.in)) : new BufferedReader(
					new FileReader("input.txt"));
			writer = onlineJudge ? new PrintWriter(new BufferedWriter(
					new OutputStreamWriter(System.out))) : new PrintWriter(
					new BufferedWriter(new FileWriter("output.txt")));
			Locale.setDefault(Locale.US);
			tokenizer = null;
			solve();
			writer.flush();
		} catch (Exception error) {
			error.printStackTrace();
			System.exit(1);
		}
	}

	class InputReader {

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                    throw new InputMismatchException();
            if (curChar >= numChars) {
                    curChar = 0;
                    try {
                            numChars = stream.read(buf);
                    } catch (IOException e) {
                            throw new InputMismatchException();
                    }
                    if (numChars <= 0)
                            return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                    c = read();
            int sgn = 1;
            if (c == '-') {
                    sgn = -1;
                    c = read();
            }
            int res = 0;
            do {
                    if (c < '0' || c > '9')
                            throw new InputMismatchException();
                    res *= 10;
                    res += c - '0';
                    c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                    c = read();
            int sgn = 1;
            if (c == '-') {
                    sgn = -1;
                    c = read();
            }
            long res = 0;
            do {
                    if (c < '0' || c > '9')
                            throw new InputMismatchException();
                    res *= 10;
                    res += c - '0';
                    c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                    c = read();
            StringBuffer res = new StringBuffer();
            do {
                    res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private String readLine0() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                    if (c != '\r')
                            buf.appendCodePoint(c);
                    c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                    s = readLine0();
            return s;
        }

        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines)
                    return readLine();
            else
                    return readLine0();
        }

        public char readCharacter() {
            int c = read();
            while (isSpaceChar(c))
                    c = read();
            return (char) c;
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                    c = read();
            int sgn = 1;
            if (c == '-') {
                    sgn = -1;
                    c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                    if (c == 'e' || c == 'E')
                            return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                            throw new InputMismatchException();
                    res *= 10;
                    res += c - '0';
                    c = read();
            }
            if (c == '.') {
                    c = read();
                    double m = 1;
                    while (!isSpaceChar(c)) {
                            if (c == 'e' || c == 'E')
                                    return res * Math.pow(10, readInt());
                            if (c < '0' || c > '9')
                                    throw new InputMismatchException();
                            m /= 10;
                            res += (c - '0') * m;
                            c = read();
                    }
            }
            return res * sgn;
        }

        private InputStream stream;
        private byte[] buf = new byte[1<<16];
        private int curChar;
        private int numChars;
	}

	private class Parser {

        public Parser(InputStream in) {
           din = new DataInputStream(in);
           buffer = new byte[BUFFER_SIZE];
           bufferPointer = bytesRead = 0;
        }

        public byte c;

        public int nextInt() throws IOException {
           int value = 0;
           c = read();
           while (c <= ' ') c = read();
           boolean neg = c == '-';
           if (neg) c = read();
           do {
              value = value*10 + c-48;
              c = read();
           }
           while (c > ' ');
           if (neg) {
               return -value;
           }
           else {
               return value;
           }
        }

        private void fillBuffer() throws IOException {
           bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
           if (bytesRead == -1) buffer[0] = -1;
        }

        public byte read() throws IOException {
           if (bufferPointer == bytesRead) fillBuffer();
           return buffer[bufferPointer++];
        }

        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        final private int BUFFER_SIZE = 1 << 16;
    }

	private BufferedReader reader;
	private PrintWriter writer;
	private StringTokenizer tokenizer;

	private void println() {
		writer.println();
	}

	private void print(Object obj) {
		writer.print(obj);
	}

	private void println(Object obj) {
		writer.println(obj);
	}

	private void printf(String f, Object... obj) {
		writer.printf(f, obj);
	}

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

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

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

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


import java.util.*;
import java.io.*;
import static java.lang.Math.*;

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

    void run() throws Exception{
        //Scanner sc = new Scanner(System.in);
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(sc.readLine());
        String[] ab = sc.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        int[] ps = new int[n];
        int[] sort = new int[n];
        StringTokenizer st = new StringTokenizer(sc.readLine(), " ");
        for(int i = 0; i < n; i++)
            sort[i] = ps[i] = Integer.parseInt(st.nextToken());
        Arrays.sort(sort);
        if(a == b){
            solveAB(a, b, ps, sort);
            return;
        }
        int[] afreq = new int[6];
        if(a > b){
            for(int i = 0; i < a; i++)
                afreq[sort[i]]++;
        }else{
            for(int i = n-1; i >= n-a; i--)
                afreq[sort[i]]++;
        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            if(i > 0)
                sb.append(" ");
            if(afreq[ps[i]] > 0){
                afreq[ps[i]]--;
                sb.append("1");
            }else{
                sb.append("2");
            }
        }
        System.out.println(sb);
    }

    void solveAB(int a, int b, int[] ps, int[] sort){
        int n = a+b;
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            if(i > 0)
                sb.append(" ");
            if(i < a)
                sb.append("1");
            else
                sb.append("2");
        }
        System.out.println(sb);
    }
}


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

/**
 * Author -
 * User: kansal
 * Date: 5/4/11
 * Time: 11:19 AM
 */
public class AverageScore {
    public static void main(String[] args) {
        reader = new BufferedReader(new InputStreamReader(System.in));

        final int n = nextInt(), a = nextInt(), b = nextInt();
        final int[] marks = new int[n];
        for(int i = 0; i < n; ++i) marks[i] = nextInt();

        if (a == b) {
            for(int i = 0; i < a; ++i) {
                System.out.print(1 + " ");
            }
            for(int i = 0; i < b; ++i) {
                System.out.print(2 + " ");
            }
            return;
        }

        Integer[] order = new Integer[n];
        for(int i = 0; i < n; ++i) {
            order[i] = i;
        }

        Arrays.sort(order, new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                if (marks[o1] != marks[o2]) {
                    return marks[o2] - marks[o1];
                }
                return (a > b) ? o1 - o2 : o2 - o1;
            }
        });

        int[] res = new int[n];
        for(int i = 0; i < Math.min(a,b); ++i) {
            res[order[i]] = a < b ? 1 : 2;
        }
        for(int i = 0; i < Math.max(a,b); ++i) {
            res[order[Math.min(a,b)+i]] = a > b ? 1 : 2;
        }

        for(int x: res) {
            System.out.print(x + " ");
        }
    }

    public static BufferedReader reader;

    public static StringTokenizer tokenizer = null;

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

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

    static public String next() {
        return nextToken();
    }

    static public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}


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

/**
 * Author -
 * User: kansal
 * Date: 5/4/11
 * Time: 11:19 AM
 */
public class AverageScore {
    public static void main(String[] args) {
        reader = new BufferedReader(new InputStreamReader(System.in));

        final int n = nextInt(), a = nextInt(), b = nextInt();
        final int[] marks = new int[n];
        for(int i = 0; i < n; ++i) marks[i] = nextInt();

        if (a == b) {
            for(int i = 0; i < a; ++i) {
                System.out.print(1 + " ");
            }
            for(int i = 0; i < b; ++i) {
                System.out.print(2 + " ");
            }
            return;
        }

        Integer[] order = new Integer[n];
        for(int i = 0; i < n; ++i) {
            order[i] = i;
        }

        Arrays.sort(order, new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                if (marks[o1] != marks[o2]) {
                    return marks[o2] - marks[o1];
                }
                return (a < b) ? o1 - o2 : o2 - o1;
            }
        });

        int[] res = new int[n];
        for(int i = 0; i < Math.min(a,b); ++i) {
            res[order[i]] = a < b ? 1 : 2;
        }
        for(int i = 0; i < Math.max(a,b); ++i) {
            res[order[Math.min(a,b)+i]] = a > b ? 1 : 2;
        }

        /*for(int i = 0; i < n/2; ++i) {
            int t = res[i];
            res[i] = res[n-i-1];
            res[n-i-1] = t;
        }*/

        for(int x: res) {
            System.out.print(x + " ");
        }
    }

    public static BufferedReader reader;

    public static StringTokenizer tokenizer = null;

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

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

    static public String next() {
        return nextToken();
    }

    static public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}


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

/**
 * Author -
 * User: kansal
 * Date: 5/4/11
 * Time: 11:19 AM
 */
public class AverageScore {
    public static void main(String[] args) {
        reader = new BufferedReader(new InputStreamReader(System.in));
        final int n = nextInt(), a = nextInt(), b = nextInt();
        final int[] marks = new int[n];
        for(int i = 0; i < n; ++i) marks[i] = nextInt();
        Integer[] order = new Integer[n];
        for(int i = 0; i < n; ++i) {
            order[i] = i;
        }
        Arrays.sort(order, new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                if (marks[o1] != marks[o2]) {
                    return marks[o2] - marks[o1];
                }
                return (a < b) ? o1 - o2 : o2 - o1;
            }
        });
        int[] res = new int[n];
        for(int i = 0; i < a; ++i) {
            res[order[i]] = 1;
        }
        for(int i = 0; i < b; ++i) {
            res[order[a+i]] = 2;
        }
        for(int x: res) {
            System.out.print(x + " ");
        }
    }

    public static BufferedReader reader;

    public static StringTokenizer tokenizer = null;

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

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

    static public String next() {
        return nextToken();
    }

    static public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	int N;
	int A;
	int B;

	int[] f;
	Item[] items;

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		N = nextInt();
		A = nextInt();
		B = nextInt();

		f = new int [N];
		items = new Item [N];

		for (int i = 0; i < N; i++)
			items[i] = new Item(nextInt(), i);

		if (A < B) {
			sort(items, new CmpDes());
			for (int i = 0; i < A; i++)
				f[items[i].ind] = 1;
			for (int i = A; i < N; i++)
				f[items[i].ind] = 2;
		} else if (A == B) {
			fill(f, 0, A, 1);
			fill(f, A, N, 2);
		} else {
			sort(items, new CmpAsc());
			for (int i = 0; i < A; i++)
				f[items[i].ind] = 1;
			for (int i = A; i < N; i++)
				f[items[i].ind] = 2;
		}

		for (int i = 0; i < N; i++) {
			if (i > 0)
				out.print(' ');
			out.print(f[i]);
		}
		out.println();

		out.close();
	}

	class Item {
		int val;
		int ind;

		Item(int val, int ind) {
			this.val = val;
			this.ind = ind;
		}
	}

	class CmpAsc implements Comparator<Item> {
		@Override
		public int compare(Item i1, Item i2) {
			if (i1.val != i2.val)
				return i1.val < i2.val ? -1 : 1;
			return i1.ind - i2.ind;
		}
	}

	class CmpDes implements Comparator<Item> {
		@Override
		public int compare(Item i1, Item i2) {
			if (i1.val != i2.val)
				return i1.val > i2.val ? -1 : 1;
			return i1.ind - i2.ind;
		}
	}

	/***************************************************************
	 * Input
	 **************************************************************/
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

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

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

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

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


/**
 * Created by ckboss on 14-10-7.
 */
import java.util.*;

public class AverageScore {

    static final int maxn=10010;
    static int[] sorce = new int[maxn];
    static int[] fen = new int[10];
    static int[] fena=new int[10];
    static int[] fenb=new int[10];
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int a=in.nextInt(),b=in.nextInt();
        for(int i=1;i<=n;i++)
        {
            sorce[i]=in.nextInt();
            fen[sorce[i]]++;
        }

        if(b-a<0){
            ///分给a的数要尽量小
            int ta=a;
            for(int i=1;i<=5&&ta>0;i++){
                if(fen[i]<=ta) {
                    fena[i]+=fen[i];
                    ta-=fen[i];
                }
                else{
                    fena[i]+=ta;
                    ta=0;
                }
            }
            for(int i=1;i<=n;i++){
                if(fena[sorce[i]]>0){
                    System.out.print(1+" ");
                    fena[sorce[i]]--;
                }
                else{
                    System.out.print(2+" ");
                }
            }
        }
        else if(b==a){
            for(int i=0;i<n;i++){
                int c;
                if(i+1<=a) c=1;
                else c=2;
                System.out.print(c+" ");
            }
        }
        else if(b-a>0){
            ///分给a的数要尽量大
            int ta=a;
            for(int i=5;i>=1&&ta>0;i--){
                if(fen[i]<=ta) {
                    fena[i]+=fen[i];
                    ta-=fen[i];
                }
                else{
                    fena[i]+=ta;
                    ta=0;
                }
            }
            //for(int i=1;i<=5;i++) fenb[i]=fen[i]-fena[i];
            for(int i=1;i<=n;i++){
                if(fena[sorce[i]]>0){
                    System.out.print(1+" ");
                    fena[sorce[i]]--;
                }
                else{
                    System.out.print(2+" ");
                }
            }
        }
        System.out.println("");
    }
}


/**
 * Created by ckboss on 14-10-7.
 */
import java.util.*;

public class AverageScore {

    static final int maxn=100100;
    static int[] sorce = new int[maxn];
    static int[] fen = new int[10];
    static int[] fena=new int[10];
    static int[] fenb=new int[10];
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int a=in.nextInt(),b=in.nextInt();
        for(int i=1;i<=n;i++)
        {
            sorce[i]=in.nextInt();
            fen[sorce[i]]++;
        }

        if(b-a<0){
            ///分给a的数要尽量小
            int ta=a;
            for(int i=1;i<=5&&ta>0;i++){
                if(fen[i]<=ta) {
                    fena[i]+=fen[i];
                    ta-=fen[i];
                }
                else{
                    fena[i]+=ta;
                    ta=0;
                }
            }
            for(int i=1;i<=n;i++){
                if(fena[sorce[i]]>0){
                    System.out.print(1+" ");
                    fena[sorce[i]]--;
                }
                else{
                    System.out.print(2+" ");
                }
            }
        }
        else if(b==a){
            for(int i=0;i<n;i++){
                int c;
                if(i+1<=a) c=1;
                else c=2;
                System.out.print(c+" ");
            }
        }
        else if(b-a>0){
            ///分给a的数要尽量大
            int ta=a;
            for(int i=5;i>=1&&ta>0;i--){
                if(fen[i]<=ta) {
                    fena[i]+=fen[i];
                    ta-=fen[i];
                }
                else{
                    fena[i]+=ta;
                    ta=0;
                }
            }
            //for(int i=1;i<=5;i++) fenb[i]=fen[i]-fena[i];
            for(int i=1;i<=n;i++){
                if(fena[sorce[i]]>0){
                    System.out.print(1+" ");
                    fena[sorce[i]]--;
                }
                else{
                    System.out.print(2+" ");
                }
            }
        }
        System.out.println("");
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;

    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }

    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }

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

    public static void main(String[] args)throws Exception {
        int n = nextInt(), a = nextInt(), b = nextInt();

        int[][] mas = new int[n][2];
        for(int i = 0; i<n; i++) {
            mas[i][0] = nextInt();
            mas[i][1] = i;
        }

        if(a == b) {
            for(int i = 0; i<n; i++) {
                out.print((i<a?1:2)+" ");
            }
            out.println();
            out.flush();
            return;
        }

        Arrays.sort(mas, new Comparator<int[]>() {
            public int compare(int[] mas1, int[] mas2) {
                if(mas1[0] != mas2[0])return mas1[0] - mas2[0];
                return mas1[1] - mas2[1];
            }
        });

        int[] ans1 = new int[n], ans2 = new int[n];
        int sum1a = 0, sum1b = 0, sum2a = 0, sum2b = 0;
        for(int i = 0;i<a; i++) {
            ans1[mas[i][1]] = 1;
            sum1a += (mas[i][0]);
        }
        for(int i = a;i<n; i++) {
            ans1[mas[i][1]] = 2;
            sum1b += (mas[i][0]);
        }

        for(int i = 0; i<b; i++) {
            ans2[mas[i][1]] = 2;
            sum2b += (mas[i][0]);
        }
        for(int i = b; i<n; i++) {
            ans2[mas[i][1]] = 1;
            sum2a += (mas[i][0]);
        }

        double sum1 = sum1a / a + sum1b / b;
        double sum2 = sum2a / a + sum2b / b;

        boolean first = false;
        if(sum1 != sum2) {
            first = sum1 > sum2;
        } else
        for(int i = 0; i<n; i++) {
            if(ans1[i] == ans2[i])continue;
            first = ans1[i] < ans2[i];
            break;
        }

        for(int i = 0; i<n; i++)out.print((first?ans1[i]:ans2[i]) + " ");
        out.println();
        out.flush();
    }

    /////////////////////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        System.out.println(o);
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    //////////////////////////////////////////////////////////////////
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
    private static StreamTokenizer in;
    private static PrintWriter out;
    private static BufferedReader inB;

    private static int nextInt() throws Exception{
        in.nextToken();
        return (int)in.nval;
    }

    private static String nextString() throws Exception{
        in.nextToken();
        return in.sval;
    }

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

    public static void main(String[] args)throws Exception {
        int n = nextInt(), a = nextInt(), b = nextInt();

        int[][] mas = new int[n][2];
        for(int i = 0; i<n; i++) {
            mas[i][0] = nextInt();
            mas[i][1] = i;
        }

        if(a == b) {
            for(int i = 0; i<n; i++) {
                out.print((i<a?1:2)+" ");
            }
            out.println();
            out.flush();
            return;
        }

        Arrays.sort(mas, new Comparator<int[]>() {
            public int compare(int[] mas1, int[] mas2) {
                if(mas1[0] != mas2[0])return mas1[0] - mas2[0];
                return mas1[1] - mas2[1];
            }
        });

        int[] ans1 = new int[n], ans2 = new int[n];
        int sum1a = 0, sum1b = 0, sum2a = 0, sum2b = 0;
        for(int i = 0;i<a; i++) {
            ans1[mas[i][1]] = 1;
            sum1a += (mas[i][0]);
        }
        for(int i = a;i<n; i++) {
            ans1[mas[i][1]] = 2;
            sum1b += (mas[i][0]);
        }

        Arrays.sort(mas, new Comparator<int[]>() {
            public int compare(int[] mas1, int[] mas2) {
                if(mas1[0] != mas2[0])return mas1[0] - mas2[0];
                return mas2[1] - mas1[1]; // here change
            }
        });

        for(int i = 0; i<b; i++) {
            ans2[mas[i][1]] = 2;
            sum2b += (mas[i][0]);
        }
        for(int i = b; i<n; i++) {
            ans2[mas[i][1]] = 1;
            sum2a += (mas[i][0]);
        }

        double sum1 = (double)sum1a / a + (double)sum1b / b;
        double sum2 = (double)sum2a / a + (double)sum2b / b;

        boolean first = false;
        if(sum1 != sum2) {
            first = sum1 > sum2;
        } else
        for(int i = 0; i<n; i++) {
            if(ans1[i] == ans2[i])continue;
            first = ans1[i] < ans2[i];
            break;
        }

        for(int i = 0; i<n; i++)out.print((first?ans1[i]:ans2[i]) + " ");
        out.println();
        out.flush();
    }

    /////////////////////////////////////////////////////////////////
    private static void println(Object o) throws Exception {
        System.out.println(o);
    }
    private static void exit(Object o) throws Exception {
        println(o);
        exit();
    }
    private static void exit() {
        System.exit(0);
    }
    //////////////////////////////////////////////////////////////////
}


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

public class TaskC {
    public static void main(String[] args) {
        try {
            boolean oj = System.getProperty("ONLINE_JUDGE") != null;
            Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
//            Reader reader = new InputStreamReader(System.in);
            Writer writer = new OutputStreamWriter(System.out);
            PrintWriter out = new PrintWriter(writer);

            Scanner in = new Scanner(new BufferedReader(reader));

            int N = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();

            int[] marksCount = new int[5];

            int[] marks = new int[N];

            for (int i = 0; i < N; ++i) {
                int m = in.nextInt();
                marks[i] = m;
                marksCount[m - 1]++;
            }

            if (B < A) {
                boolean[] useMarkInB = new boolean[N];
                int toUse = B;
                outer:
                for (int i = 4; i >= 0; --i) {
                    if (toUse > marksCount[i]) {
                        for (int j = N - 1; j >= 0; --j) {
                            if (marks[j] == i + 1) {
                                useMarkInB[j] = true;
                                toUse--;
                                if (toUse == 0) break outer;
                            }
                        }
                    } else {
                        for (int j = N - 1; j >= 0; --j) {
                            if (marks[j] == i + 1) {
                                useMarkInB[j] = true;
                                toUse--;
                                if (toUse == 0) break outer;
                            }
                        }
                    }
                }
                for (int i = 0; i < N; ++i) {
                    System.out.print(useMarkInB[i] ? "2 " : "1 ");
                }
            } else if (B > A) {
                boolean[] useMarkInA = new boolean[N];
                int toUse = A;
                outer:
                for (int i = 4; i >= 0; --i) {
                    if (toUse > marksCount[i]) {
                        for (int j = N - 1; j >= 0; --j) {
                            if (marks[j] == i + 1) {
                                useMarkInA[j] = true;
                                toUse--;
                                if (toUse == 0) break outer;
                            }
                        }
                    } else {
                        for (int j = 0; j < N; ++j) {
                            if (marks[j] == i + 1) {
                                useMarkInA[j] = true;
                                toUse--;
                                if (toUse == 0) break outer;
                            }
                        }
                    }
                }
                for (int i = 0; i < N; ++i) {
                    System.out.print(useMarkInA[i] ? "1 " : "2 ");
                }
            } else { // A==B
                for (int i = 1; i <= A; ++i) {
                    System.out.print("1 ");
                }
                for (int i = 1; i <= B; ++i) {
                    System.out.print("2 ");
                }
            }
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


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

public class TaskC {
    public static void main(String[] args) {
        try {
            boolean oj = System.getProperty("ONLINE_JUDGE") != null;
            Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
//            Reader reader = new InputStreamReader(System.in);
            Writer writer = new OutputStreamWriter(System.out);
            PrintWriter out = new PrintWriter(writer);

            Scanner in = new Scanner(new BufferedReader(reader));

            int N = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();

            int[] marksCount = new int[5];

            int[] marks = new int[N];

            for (int i = 0; i < N; ++i) {
                int m = in.nextInt();
                marks[i] = m;
                marksCount[m - 1]++;
            }

            if (B < A) {
                boolean[] useMarkInB = new boolean[N];
                int toUse = B;
                outer:
                for (int i = 4; i >= 0; --i) {
                    for (int j = N - 1; j >= 0; --j) {
                        if (marks[j] == i + 1) {
                            useMarkInB[j] = true;
                            toUse--;
                            if (toUse == 0) break outer;
                        }
                    }
                }
                for (int i = 0; i < N; ++i) {
                    System.out.print(useMarkInB[i] ? "2 " : "1 ");
                }
            } else if (B > A) {
                boolean[] useMarkInA = new boolean[N];
                int toUse = A;
                outer:
                for (int i = 4; i >= 0; --i) {
                    for (int j = N - 1; j >= 0; --j) {
                        if (marks[j] == i + 1) {
                            useMarkInA[j] = true;
                            toUse--;
                            if (toUse == 0) break outer;
                        }
                    }
                }
                for (int i = 0; i < N; ++i) {
                    System.out.print(useMarkInA[i] ? "1 " : "2 ");
                }
            } else { // A==B
                for (int i = 1; i <= A; ++i) {
                    System.out.print("1 ");
                }
                for (int i = 1; i <= B; ++i) {
                    System.out.print("2 ");
                }
            }
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


import java.util.*;

/**
 * created at 04.05.11
 *
 * @author V.Zubchevskiy
 */
public class C
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        List<SwappedPair> marks = new ArrayList<SwappedPair>();
        for (int i = 0; i < n; i++)
        {
            marks.add(new SwappedPair(s.nextInt(), i));
        }
        Collections.sort(marks);
        int idx[] = new int[n];
        if (a > b)
        {
            Arrays.fill(idx, 2);
            for(int i =0; i < a; i++)
                idx[marks.get(i).idx] = 1;
        }
        else
        {
            Arrays.fill(idx, 1);
            for(int i =0; i < b; i++)
                idx[marks.get(i).idx] = 2;
        }

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++)
        {
            sb.append(idx[i]);
            if (i < n-1)
            sb.append(" ");
        }

        System.out.println(sb);

    }

    private static SwappedPair revert(SwappedPair swap)
    {
        return new SwappedPair(swap.idx, swap.value);

    }

    private static double avg(Collection<Integer> bMarks, int[] m)
    {
        int sum = 0;
        for (Integer bMark : bMarks)
            sum += m[bMark];
        return ((double) sum) / bMarks.size();
    }

    private static SwappedPair swap(int[] m, Collection<Integer> aMarks, Collection<Integer> bMarks)
    {
        int bMin = min(bMarks, m);
        int aMax = max(aMarks, m);
        bMarks.remove(new Integer(bMin));
        aMarks.remove(new Integer(aMax));
        aMarks.add(bMin);
        bMarks.add(aMax);
        return new SwappedPair(aMax, bMin);
    }

    private static int max(Collection<Integer> bMarks, int[] m)
    {
        int max = bMarks.iterator().next();
        for (Integer bMark : bMarks)
            if (m[max] < m[bMark])
                max = bMark;
        return max;
    }

    private static int min(Collection<Integer> bMarks, int[] m)
    {
        int min = bMarks.iterator().next();
        for (Integer bMark : bMarks)
            if (m[min] > m[bMark])
                min =bMark;
        return min;
    }

    static class SwappedPair implements Comparable<SwappedPair>
    {
        final int value;
        final int idx;

        SwappedPair(int a, int idx)
        {
            this.value = a;
            this.idx = idx;
        }

        public int compareTo(SwappedPair o)
        {
            int diff = value - o.value;
            return diff != 0 ? diff : idx - o.idx;
        }
    }
}


import java.util.*;

/**
 * created at 04.05.11
 *
 * @author V.Zubchevskiy
 */
public class C
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        List<SwappedPair> marks = new ArrayList<SwappedPair>();
        for (int i = 0; i < n; i++)
        {
            marks.add(new SwappedPair(s.nextInt(), i));
        }
        int idx[] = new int[n];
        if (a == b)
        {
            Arrays.fill(idx, 0, a, 1);
            Arrays.fill(idx, a, n, 2);
        }
        else
        {
            if (a > b)
            {
                Collections.sort(marks, new Comparator<SwappedPair>()
                {
                    public int compare(SwappedPair o1, SwappedPair o2)
                    {
                        int diff = o1.value - o2.value;
                        return diff != 0 ? diff : o1.idx - o2.idx;
                    }
                });

            }
            else
            {
                Collections.sort(marks, new Comparator<SwappedPair>()
                {
                    public int compare(SwappedPair o1, SwappedPair o2)
                    {
                        int diff = o2.value - o1.value;
                        return diff != 0 ? diff : o1.idx - o2.idx;
                    }
                });

            }
            Arrays.fill(idx, 2);
            for (int i = 0; i < a; i++)
                idx[marks.get(i).idx] = 1;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
        {
            sb.append(idx[i]);
            if (i < n - 1)
                sb.append(" ");
        }

        System.out.println(sb);

    }

    static class SwappedPair
    {
        final int value;
        final int idx;

        SwappedPair(int a, int idx)
        {
            this.value = a;
            this.idx = idx;
        }

    }
}


import java.util.Collection;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * created at 04.05.11
 *
 * @author V.Zubchevskiy
 */
public class C
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        int m[] = new int[n];
        for (int i = 0; i < n; i++)
        {
            m[i] = s.nextInt();
        }
        Set<Integer> aMarks = new HashSet<Integer>();
        for (int i = 0; i < a; i++)
        {
            aMarks.add(i);
        }
        Set<Integer> bMarks = new HashSet<Integer>();
        for (int i = a; i < n; i++)
        {
            bMarks.add(i);
        }

        double aAvg = avg(aMarks, m);
        double bAvg = avg(bMarks, m);

        double prev = 0;
        double newAvg = aAvg + bAvg;

        SwappedPair pair = null;
        while (newAvg > prev)
        {
            prev = newAvg;

            if (aAvg > bAvg)
                pair = swap(m, aMarks, bMarks);
            else
                pair = revert(swap(m, bMarks, aMarks));

            aAvg = avg(aMarks, m);
            bAvg = avg(bMarks, m);

            newAvg = aAvg + bAvg;

        }

        if (pair != null)
        {
            bMarks.remove(new Integer(pair.a));
            bMarks.add(pair.b);
            aMarks.remove(new Integer(pair.b));
            aMarks.add(pair.a);
        }

        int[] mi = new int[n];
        for (Integer aMark : aMarks)
            mi[aMark] = 1;
        for (Integer bMark : bMarks)
            mi[bMark] = 2;

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++)
        {
            sb.append(mi[i]);
            if (i < n-1)
            sb.append(" ");
        }

        System.out.println(sb);

    }

    private static SwappedPair revert(SwappedPair swap)
    {
        return new SwappedPair(swap.b, swap.a);

    }

    private static double avg(Collection<Integer> bMarks, int[] m)
    {
        int sum = 0;
        for (Integer bMark : bMarks)
            sum += m[bMark];
        return ((double) sum) / bMarks.size();
    }

    private static SwappedPair swap(int[] m, Collection<Integer> aMarks, Collection<Integer> bMarks)
    {
        int bMin = min(bMarks, m);
        int aMax = max(aMarks, m);
        bMarks.remove(new Integer(bMin));
        aMarks.remove(new Integer(aMax));
        aMarks.add(bMin);
        bMarks.add(aMax);
        return new SwappedPair(aMax, bMin);
    }

    private static int max(Collection<Integer> bMarks, int[] m)
    {
        int max = 0;
        for (Integer bMark : bMarks)
            if (m[max] < m[bMark])
                max = bMark;
        return max;
    }

    private static int min(Collection<Integer> bMarks, int[] m)
    {
        int min = 0;
        for (Integer bMark : bMarks)
            if (m[min] > m[bMark])
                min =bMark;
        return min;
    }

    static class SwappedPair
    {
        final int a;
        final int b;

        SwappedPair(int a, int b)
        {
            this.a = a;
            this.b = b;
        }
    }
}


import java.util.Collection;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * created at 04.05.11
 *
 * @author V.Zubchevskiy
 */
public class C
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        int m[] = new int[n];
        for (int i = 0; i < n; i++)
        {
            m[i] = s.nextInt();
        }
        Set<Integer> aMarks = new HashSet<Integer>();
        for (int i = 0; i < a; i++)
        {
            aMarks.add(i);
        }
        Set<Integer> bMarks = new HashSet<Integer>();
        for (int i = a; i < n; i++)
        {
            bMarks.add(i);
        }

        double aAvg = avg(aMarks, m);
        double bAvg = avg(bMarks, m);

        double prev = 0;
        double newAvg = aAvg + bAvg;

        SwappedPair pair = null;
        while (newAvg > prev)
        {
            prev = newAvg;

            if (aAvg > bAvg)
                pair = swap(m, aMarks, bMarks);
            else
                pair = revert(swap(m, bMarks, aMarks));

            aAvg = avg(aMarks, m);
            bAvg = avg(bMarks, m);

            newAvg = aAvg + bAvg;

        }

        if (pair != null)
        {
            bMarks.remove(new Integer(pair.a));
            bMarks.add(pair.b);
            aMarks.remove(new Integer(pair.b));
            aMarks.add(pair.a);
        }

        int[] mi = new int[n];
        for (Integer aMark : aMarks)
            mi[aMark] = 1;
        for (Integer bMark : bMarks)
            mi[bMark] = 2;

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++)
        {
            sb.append(mi[i]);
            if (i < n-1)
            sb.append(" ");
        }

        System.out.println(sb);

    }

    private static SwappedPair revert(SwappedPair swap)
    {
        return new SwappedPair(swap.b, swap.a);

    }

    private static double avg(Collection<Integer> bMarks, int[] m)
    {
        int sum = 0;
        for (Integer bMark : bMarks)
            sum += m[bMark];
        return ((double) sum) / bMarks.size();
    }

    private static SwappedPair swap(int[] m, Collection<Integer> aMarks, Collection<Integer> bMarks)
    {
        int bMin = min(bMarks, m);
        int aMax = max(aMarks, m);
        bMarks.remove(new Integer(bMin));
        aMarks.remove(new Integer(aMax));
        aMarks.add(bMin);
        bMarks.add(aMax);
        return new SwappedPair(aMax, bMin);
    }

    private static int max(Collection<Integer> bMarks, int[] m)
    {
        int max = bMarks.iterator().next();
        for (Integer bMark : bMarks)
            if (m[max] < m[bMark])
                max = bMark;
        return max;
    }

    private static int min(Collection<Integer> bMarks, int[] m)
    {
        int min = bMarks.iterator().next();
        for (Integer bMark : bMarks)
            if (m[min] > m[bMark])
                min =bMark;
        return min;
    }

    static class SwappedPair
    {
        final int a;
        final int b;

        SwappedPair(int a, int b)
        {
            this.a = a;
            this.b = b;
        }
    }
}


/**
 *
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Locale;
import java.util.StringTokenizer;

/**
 * @author yxq
 * @data 2014年8月8日下午11:17:05
 * @version jdk1.7
 * @package Acm
 * @fileName Main15.java
 */
public class Main {
	public static void main(String[] args) {

		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer strTok = new StringTokenizer("");

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.flush();
		out.close();
		in.close();
	}

	/**
	 * @return
	 * @throws IOException
	 */
	private Object solve() throws IOException {
		int n, a, b;
		int[] f = new int[100010];
		int[] dp = new int[100010];
		while (EOF() != true) {
			n = ni();
			for (int i = 1; i <= 100000; i++) {
				dp[i] = 0;
				f[i] = 0;
			}

			for (int i = 1; i <= n; i++) {
				f[ni()]++;
			}
			dp[1] = f[1];
			dp[2] = f[2] * 2;
			for (int i = 2; i <= 100000; i++) {
				dp[i] = Math.max(dp[i - 1], dp[i - 2] + f[i] * i);
			}
			out.println(dp[100000]);
			out.flush();
		}

		return null;
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	String nextToken() throws IOException {
		while (!strTok.hasMoreTokens())
			strTok = new StringTokenizer(in.readLine());
		return strTok.nextToken();
	}

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

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

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

	BigInteger nextBigInteger() throws IOException {
		return new BigInteger(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		strTok = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!strTok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			strTok = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	public void pln() {
		out.println();
	}

	public void pln(int arg) {
		out.println(arg);
	}

	public void pln(long arg) {
		out.println(arg);
	}

	public void pln(double arg) {
		out.println(arg);
	}

	public void pln(String arg) {
		out.println(arg);
	}

	public void pln(boolean arg) {
		out.println(arg);
	}

	public void pln(char arg) {
		out.println(arg);
	}

	public void pln(float arg) {
		out.println(arg);
	}

	public void pln(Object arg) {
		out.println(arg);
	}

	public void p(int arg) {
		out.print(arg);
	}

	public void p(long arg) {
		out.print(arg);
	}

	public void p(double arg) {
		out.print(arg);
	}

	public void p(String arg) {
		out.print(arg);
	}

	public void p(boolean arg) {
		out.print(arg);
	}

	public void p(char arg) {
		out.print(arg);
	}

	public void p(float arg) {
		out.print(arg);
	}

	public void p(Object arg) {
		out.print(arg);
	}
}


/**
 *
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Locale;
import java.util.StringTokenizer;

/**
 * @author yxq
 * @data 2014年8月8日下午11:17:05
 * @version jdk1.7
 * @package Acm
 * @fileName Main15.java
 */
public class Main {
	public static void main(String[] args) {

		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer strTok = new StringTokenizer("");

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.flush();
		out.close();
		in.close();
	}

	/**
	 * @return
	 * @throws IOException
	 */
	private Object solve() throws IOException {
		int n, a, b;
		int[] f = new int[100010];
		long[] dp = new long[100010];
		while (EOF() != true) {
			n = ni();
			for (int i = 1; i <= 100000; i++) {
				dp[i] = 0;
				f[i] = 0;
			}

			for (int i = 1; i <= n; i++) {
				f[ni()]++;
			}
			dp[1] = f[1];
			dp[2] = f[2] * 2;
			for (int i = 2; i <= 100000; i++) {
				dp[i] = Math.max(dp[i - 1], dp[i - 2] + f[i] * i);
			}
			out.println(dp[100000]);
			out.flush();
		}

		return null;
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	String nextToken() throws IOException {
		while (!strTok.hasMoreTokens())
			strTok = new StringTokenizer(in.readLine());
		return strTok.nextToken();
	}

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

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

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

	BigInteger nextBigInteger() throws IOException {
		return new BigInteger(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		strTok = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!strTok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			strTok = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	public void pln() {
		out.println();
	}

	public void pln(int arg) {
		out.println(arg);
	}

	public void pln(long arg) {
		out.println(arg);
	}

	public void pln(double arg) {
		out.println(arg);
	}

	public void pln(String arg) {
		out.println(arg);
	}

	public void pln(boolean arg) {
		out.println(arg);
	}

	public void pln(char arg) {
		out.println(arg);
	}

	public void pln(float arg) {
		out.println(arg);
	}

	public void pln(Object arg) {
		out.println(arg);
	}

	public void p(int arg) {
		out.print(arg);
	}

	public void p(long arg) {
		out.print(arg);
	}

	public void p(double arg) {
		out.print(arg);
	}

	public void p(String arg) {
		out.print(arg);
	}

	public void p(boolean arg) {
		out.print(arg);
	}

	public void p(char arg) {
		out.print(arg);
	}

	public void p(float arg) {
		out.print(arg);
	}

	public void p(Object arg) {
		out.print(arg);
	}
}


/**
 *
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Locale;
import java.util.StringTokenizer;

/**
 * @author yxq
 * @data 2014年8月8日下午11:17:05
 * @version jdk1.7
 * @package Acm
 * @fileName Main15.java
 */
public class Main{
	public static void main(String[] args) {

		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer strTok = new StringTokenizer("");

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.flush();
		out.close();
		in.close();
	}

	/**
	 * @return
	 * @throws IOException
	 */
	private Object solve() throws IOException {
		int n, a, b;
		int[] f = new int[100010];
		int[] dp = new int[100010];
		while (EOF() != true) {
			n = ni();
			for (int i = 1; i <= 100000; i++) {
				dp[i] = 0;
				f[i] = 0;
			}

			for (int i = 1; i <= n; i++) {
				f[ni()]++;
			}
			dp[1] = f[1];
			dp[2] = f[2] * 2;
			for (int i = 3; i <= 100000; i++) {
				dp[i] = Math.max(dp[i - 1], dp[i - 2] + f[i] * i);
			}
			out.println(dp[100000]);
			out.flush();
		}

		return null;
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	String nextToken() throws IOException {
		while (!strTok.hasMoreTokens())
			strTok = new StringTokenizer(in.readLine());
		return strTok.nextToken();
	}

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

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

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

	BigInteger nextBigInteger() throws IOException {
		return new BigInteger(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		strTok = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!strTok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			strTok = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	public void pln() {
		out.println();
	}

	public void pln(int arg) {
		out.println(arg);
	}

	public void pln(long arg) {
		out.println(arg);
	}

	public void pln(double arg) {
		out.println(arg);
	}

	public void pln(String arg) {
		out.println(arg);
	}

	public void pln(boolean arg) {
		out.println(arg);
	}

	public void pln(char arg) {
		out.println(arg);
	}

	public void pln(float arg) {
		out.println(arg);
	}

	public void pln(Object arg) {
		out.println(arg);
	}

	public void p(int arg) {
		out.print(arg);
	}

	public void p(long arg) {
		out.print(arg);
	}

	public void p(double arg) {
		out.print(arg);
	}

	public void p(String arg) {
		out.print(arg);
	}

	public void p(boolean arg) {
		out.print(arg);
	}

	public void p(char arg) {
		out.print(arg);
	}

	public void p(float arg) {
		out.print(arg);
	}

	public void p(Object arg) {
		out.print(arg);
	}
}


/**
 *
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Locale;
import java.util.StringTokenizer;

/**
 * @author yxq
 * @data 2014年8月8日下午11:17:05
 * @version jdk1.7
 * @package Acm
 * @fileName Main15.java
 */
public class Main {
	public static void main(String[] args) {

		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer strTok = new StringTokenizer("");

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.flush();
		out.close();
		in.close();
	}

	/**
	 * @return
	 * @throws IOException
	 */
	private Object solve() throws IOException {
		int n, a, b;
		int[] f = new int[100010];
		long[] dp = new long[100010];
		while (EOF() != true) {
			n = ni();
			for (int i = 1; i <= 100000; i++) {
				dp[i] = 0;
				f[i] = 0;
			}

			for (int i = 1; i <= n; i++) {
				f[ni()]++;
			}
			dp[1] = f[1];
			for (int i = 2; i <= 100000; i++) {
				dp[i] = Math.max(dp[i - 1], dp[i - 2] + f[i] *1l* i);
			}
			out.println(dp[100000]);
			out.flush();
		}

		return null;
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	String nextToken() throws IOException {
		while (!strTok.hasMoreTokens())
			strTok = new StringTokenizer(in.readLine());
		return strTok.nextToken();
	}

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

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

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

	BigInteger nextBigInteger() throws IOException {
		return new BigInteger(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		strTok = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!strTok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			strTok = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	public void pln() {
		out.println();
	}

	public void pln(int arg) {
		out.println(arg);
	}

	public void pln(long arg) {
		out.println(arg);
	}

	public void pln(double arg) {
		out.println(arg);
	}

	public void pln(String arg) {
		out.println(arg);
	}

	public void pln(boolean arg) {
		out.println(arg);
	}

	public void pln(char arg) {
		out.println(arg);
	}

	public void pln(float arg) {
		out.println(arg);
	}

	public void pln(Object arg) {
		out.println(arg);
	}

	public void p(int arg) {
		out.print(arg);
	}

	public void p(long arg) {
		out.print(arg);
	}

	public void p(double arg) {
		out.print(arg);
	}

	public void p(String arg) {
		out.print(arg);
	}

	public void p(boolean arg) {
		out.print(arg);
	}

	public void p(char arg) {
		out.print(arg);
	}

	public void p(float arg) {
		out.print(arg);
	}

	public void p(Object arg) {
		out.print(arg);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class C260C {

	public static void main(String args[]) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		StreamTokenizer st = new StreamTokenizer(bf);
		st.nextToken();
		int n = (int) st.nval;
		int[] a = new int[1000002];
		int max = 0;
		for (int i = 0; i < n; i++) {
			st.nextToken();
			int x = (int) st.nval;
			max = Math.max(x, max);
			a[x]++;
		}
	int[] dp=new int[max+1];
	dp[1]=a[1]*1;
	dp[2]=Math.max(dp[1], 2*a[2]);
		for(int i=3;i<=max;i++){
			dp[i]=Math.max(dp[i-3]+i*a[i], Math.max(dp[i-2]+i*a[i], dp[i-1]));
		}
		System.out.println(dp[max]);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class C260C {

	public static void main(String args[]) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		StreamTokenizer st = new StreamTokenizer(bf);
		st.nextToken();
		int n = (int) st.nval;
		int[] a = new int[1000002];
		int max = 0;
		for (int i = 0; i < n; i++) {
			st.nextToken();
			int x = (int) st.nval;
			max = Math.max(x, max);
			a[x]++;
		}
		long res1 = 0;
		long res2 = 0;
		for (int i = max; i >= 0; i -= 2) {
			res1 += (i * a[i]);
		}

		for (int i = max - 1; i >= 0; i -= 2) {
			res2 += (i * a[i]);
		}
//System.out.println(res1+" "+res2);
		System.out.println(Math.max(res1, res2));
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class C260C {

	public static void main(String args[]) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		StreamTokenizer st = new StreamTokenizer(bf);
		st.nextToken();
		int n = (int) st.nval;
		long[] a = new long[1000002];
		int max = 0;
		for (int i = 0; i < n; i++) {
			st.nextToken();
			int x = (int) st.nval;
			max = Math.max(x, max);
			a[x]++;
//			System.out.println("taking");
		}
//		System.out.println("reached");
		long[] dp = new long[max + 1];
		dp[1] = a[1] * 1;
		dp[2] = Math.max(dp[1], 2 * a[2]);
		for (int i = 3; i <= max; i++) {
//			System.out.println("doing");
			dp[i] = Math.max(dp[i - 3] + i * a[i],
					Math.max(dp[i - 2] + i * a[i], dp[i - 1]));
		}
		System.out.println(dp[max]);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class C260C {

	public static void main(String args[]) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		StreamTokenizer st = new StreamTokenizer(bf);
		st.nextToken();
		int n = (int) st.nval;
		int[] a = new int[1000002];
		int max = 0;
		for (int i = 0; i < n; i++) {
			st.nextToken();
			int x = (int) st.nval;
			max = Math.max(x, max);
			a[x]++;
		}
	long[] dp=new long[max+1];
	dp[1]=a[1]*1;
	dp[2]=Math.max(dp[1], 2*a[2]);
		for(int i=3;i<=max;i++){
			dp[i]=Math.max(dp[i-3]+i*a[i], Math.max(dp[i-2]+i*a[i], dp[i-1]));
		}
		System.out.println(dp[max]);

	}

}


import java.util.Scanner;

public class A {

  public static void main(String[] args) {
    Scanner inScanner = new Scanner(System.in);
    int n = inScanner.nextInt();
    long[] a = new long[100001];
    for (int i = 0; i < n; i++) {
      a[inScanner.nextInt()]++;
    }
    long[] max = new long[100001];
    max[0] = 0;
    max[1] = a[1];
    for (int i = 2; i <= 100000; i++) {
      max[i] = Math.max(max[i - 1], max[i - 2] + a[i] * i);
    }
    System.out.println(max[100000]);
  }
}


/**
 * Class: ProblemX

 * Date: 2014/08/08 23:30

 * Description:

 *
 * @author Laiping Zhou(sjtudesigner)
 */
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class ProblemX {

    private static ArrayList<Integer> al = new ArrayList<Integer>();
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int score = 0;
        int n = sc.nextInt();
        int[] list = new int[n];

        for (int i = 0;i < n;i++)
        {
            list[i] = sc.nextInt();
        }
        Arrays.sort(list);

        int last = list[0] - 1;
        for (int i = 0;i <= n;i++)
        {
            if (i == n || list[i] != last + 1)
            {
                score += cal_score(al);
                al.clear();
                if (i != n)
                    last = list[i] - 1;
                else break;
                i--;
                continue;
            }
            int times = 0;
            while (i < n && list[i] == last + 1)
            {
                times++;
                i++;
            }
            al.add(al.size(), times * (last + 1));
            last++;
            i--;
        }
        System.out.println(score);
    }

    private static int cal_score(ArrayList<Integer> al) {

        int[] dp = new int[al.size() + 1];
        if (al.size() == 1) return al.get(0);
        for (int i = 2;i <= al.size();i++)
        {
            dp[i] = Math.max(al.get(i - 2) + dp[i - 2], dp[i]);
            if (i % 2 == 0 && dp[i] < dp[i - 1]) dp[i] = dp[i - 1];
        }
        return Math.max(dp[al.size()], dp[al.size() - 1] + al.get(al.size() - 1));
    }

}


/**
 * Class: ProblemX

 * Date: 2014/08/08 23:30

 * Description:

 *
 * @author Laiping Zhou(sjtudesigner)
 */
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class ProblemX {

    private static ArrayList<Integer> al = new ArrayList<Integer>();
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        long score = 0;
        int n = sc.nextInt();
        int[] list = new int[n];

        for (int i = 0;i < n;i++)
        {
            list[i] = sc.nextInt();
        }
        Arrays.sort(list);

        int last = list[0] - 1;
        for (int i = 0;i <= n;i++)
        {
            if (i == n || list[i] != last + 1)
            {
                score += cal_score(al);
                al.clear();
                if (i != n)
                    last = list[i] - 1;
                else break;
                i--;
                continue;
            }
            int times = 0;
            while (i < n && list[i] == last + 1)
            {
                times++;
                i++;
            }
            al.add(al.size(), times * (last + 1));
            last++;
            i--;
        }
        System.out.println(score);
    }

    private static int cal_score(ArrayList<Integer> al) {

        int[] dp = new int[al.size() + 1];
        if (al.size() == 1) return al.get(0);
        for (int i = 2;i <= al.size();i++)
        {
            dp[i] = Math.max(al.get(i - 2) + dp[i - 2], dp[i]);
            if (dp[i] < dp[i - 1]) dp[i] = dp[i - 1];
        }
        return Math.max(dp[al.size()], dp[al.size() - 1] + al.get(al.size() - 1));
    }

}


/**
 * Class: ProblemX

 * Date: 2014/08/08 23:30

 * Description:

 *
 * @author Laiping Zhou(sjtudesigner)
 */
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class ProblemX {

    private static ArrayList<Long> al = new ArrayList<Long>();
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        long score = 0;
        int n = sc.nextInt();
        int[] list = new int[n];

        for (int i = 0;i < n;i++)
        {
            list[i] = sc.nextInt();
        }
        Arrays.sort(list);

        int last = list[0] - 1;
        for (int i = 0;i <= n;i++)
        {
            if (i == n || list[i] != last + 1)
            {
                score += cal_score(al);
                al.clear();
                if (i != n)
                    last = list[i] - 1;
                else break;
                i--;
                continue;
            }
            int times = 0;
            while (i < n && list[i] == last + 1)
            {
                times++;
                i++;
            }
            al.add(al.size(), (long)times * (last + 1));
            last++;
            i--;
        }
        System.out.println(score);
    }

    private static long cal_score(ArrayList<Long> al) {

        long[] dp = new long[al.size() + 1];
        if (al.size() == 1) return al.get(0);
        for (int i = 2;i <= al.size();i++)
        {
            dp[i] = Math.max(al.get(i - 2) + dp[i - 2], dp[i]);
            if (dp[i] < dp[i - 1]) dp[i] = dp[i - 1];
        }
        return Math.max(dp[al.size()], dp[al.size() - 1] + al.get(al.size() - 1));
    }

}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int[] counters = new int[100001];
        for(int i=0; i<n; i++)
            counters[a[i]]++;
        int[] dp = new int[100001];
        for(int i=100000; i>0; i--) {
            if(i == 100000) dp[i] = i*counters[i];
            else if(i==99999) dp[i] = Math.max(dp[100000], i*counters[i]);
            else dp[i] = Math.max(dp[i+1], i*counters[i] + dp[i+2]);
        }
        System.out.println(dp[1]);
        // int n = Integer.parseInt(st.nextToken());
        // int n = scan.nextInt();

        // out.close(); System.exit(0);
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        long[] counters = new long[100001];
        for(int i=0; i<n; i++)
            counters[a[i]]++;
        long[] dp = new long[100001];
        for(int i=100000; i>0; i--) {
            if(i == 100000) dp[i] = i*counters[i];
            else if(i==99999) dp[i] = Math.max(dp[100000], i*counters[i]);
            else dp[i] = Math.max(dp[i+1], i*counters[i] + dp[i+2]);
        }
        System.out.println(dp[1]);
        // int n = Integer.parseInt(st.nextToken());
        // int n = scan.nextInt();

        // out.close(); System.exit(0);
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int[] counters = new int[100001];
        for(int i=0; i<n; i++)
            counters[a[i]]++;
        long[] dp = new long[100001];
        for(int i=100000; i>0; i--) {
            if(i == 100000) dp[i] = i*counters[i];
            else if(i==99999) dp[i] = Math.max(dp[100000], i*counters[i]);
            else dp[i] = Math.max(dp[i+1], i*counters[i] + dp[i+2]);
        }
        System.out.println(dp[1]);
        // int n = Integer.parseInt(st.nextToken());
        // int n = scan.nextInt();

        // out.close(); System.exit(0);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProblemC {

    private ProblemC() throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        rd.readLine();
        String h = rd.readLine();
        String[] q = h.split("\\s+");
        int[] c = new int[100001];
        for(int i=0;i<q.length;i++) {
            int a = Integer.parseInt(q[i]);
            c[a]++;
        }
        int [] d = new int[100001];
        d[1] = c[1];
        for(int i=2;i<=100000;i++) {
            d[i] = Math.max(c[i]*i + d[i-2], d[i-1]);
        }
        out(d[100000]);
    }

    private static void out(Object x) {
        System.out.println(x);
    }

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProblemC {

    private ProblemC() throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        rd.readLine();
        String h = rd.readLine();
        String[] q = h.split("\\s+");
        int[] c = new int[100001];
        for(int i=0;i<q.length;i++) {
            int a = Integer.parseInt(q[i]);
            c[a]++;
        }
        long [] d = new long[100001];
        d[1] = c[1];
        for(int i=2;i<=100000;i++) {
            d[i] = Math.max(((long)c[i])*i + d[i-2], d[i-1]);
        }
        out(d[100000]);
    }

    private static void out(Object x) {
        System.out.println(x);
    }

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


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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;

	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}

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

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

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

	int []a;
	long [][]dp;
	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt();
		a = new int[100001];
		for(int i=0;i<n;i++) a[nextInt()]++;
		dp = new long[a.length][2];
		dp[1][0] = 0;
		dp[1][1] = a[1];

		for(int i=2;i<a.length;i++){
			dp[i][0] = Math.max(dp[i-1][1], dp[i-1][0]);
			dp[i][1] = dp[i-1][0] + 1L * i * a[i];
		}

		out.println(Math.max(dp[a.length-1][0], dp[a.length-1][1]));
		out.close();
	}

	// private long go(int pos) {
	// 	if (pos == 0) return 0;
	// 	if (pos == 1) return a[1];
	// 	if (pos == 2) return Math.max(a[1], 2 * a[2]);
	// 	while(pos >= 0 && a[pos] == 0) pos--;
	// 	if (pos < 0) return 0;
	// 	if (dp[pos] != -1) return dp[pos];
	// 	long ret = go(pos-2) + pos * a[pos];
	// 	ret = Math.max(ret, go(pos-3) + (pos-1) * a[pos-1]);

	// 	return dp[pos] = ret;
	// }

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


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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;

	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}

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

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

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

	int []a;
	long [][]dp;
	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt();
		a = new int[100001];
		for(int i=0;i<n;i++) a[nextInt()]++;
		dp = new long[a.length][2];
		dp[1][0] = 0;
		dp[1][1] = a[1];

		for(int i=2;i<a.length;i++){
			if (a[i] == 0) {
				dp[i][0] = dp[i][1] = Math.max(dp[i-1][1], dp[i-1][0]);
			}else {
				dp[i][0] = dp[i-1][1];
				dp[i][1] = Math.max(dp[i-1][0] + i * a[i], dp[i-1][1]);
			}
		}

		out.println(Math.max(dp[a.length-1][0], dp[a.length-1][1]));
		out.close();
	}

	// private long go(int pos) {
	// 	if (pos == 0) return 0;
	// 	if (pos == 1) return a[1];
	// 	if (pos == 2) return Math.max(a[1], 2 * a[2]);
	// 	while(pos >= 0 && a[pos] == 0) pos--;
	// 	if (pos < 0) return 0;
	// 	if (dp[pos] != -1) return dp[pos];
	// 	long ret = go(pos-2) + pos * a[pos];
	// 	ret = Math.max(ret, go(pos-3) + (pos-1) * a[pos-1]);

	// 	return dp[pos] = ret;
	// }

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


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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;

	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}

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

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

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

	int []a;
	long [][]dp;
	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt();
		a = new int[100001];
		for(int i=0;i<n;i++) a[nextInt()]++;
		dp = new long[a.length][2];
		dp[1][0] = 0;
		dp[1][1] = a[1];

		for(int i=2;i<a.length;i++){
			dp[i][0] = Math.max(dp[i-1][1], dp[i-1][0]);
			dp[i][1] = dp[i-1][0] + i * a[i];
		}

		out.println(Math.max(dp[a.length-1][0], dp[a.length-1][1]));
		out.close();
	}

	// private long go(int pos) {
	// 	if (pos == 0) return 0;
	// 	if (pos == 1) return a[1];
	// 	if (pos == 2) return Math.max(a[1], 2 * a[2]);
	// 	while(pos >= 0 && a[pos] == 0) pos--;
	// 	if (pos < 0) return 0;
	// 	if (dp[pos] != -1) return dp[pos];
	// 	long ret = go(pos-2) + pos * a[pos];
	// 	ret = Math.max(ret, go(pos-3) + (pos-1) * a[pos-1]);

	// 	return dp[pos] = ret;
	// }

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


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

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

        int n = in.nextInt();
         ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(in.nextInt());

        }
        Collections.sort(a);

        System.out.println(count(a));

    }

    public static int count(ArrayList<Integer> al){
        if (al.size() == 1) {
            return al.get(0);
        }
        if (al.size() == 2) {
            if (al.get(0)==al.get(1)-1) {
                return al.get(1);
            }
            else if(al.get(1)==al.get(0)-1){
                return al.get(0);
            }
            else {
                return al.get(1)+al.get(0);
            }
        }
        if (al.isEmpty()) {
            return 0;
        }
        else{
            int flag = 0;
        int size2 = 0;
        int size3 = 0;
        int size = (al.size())/2;
        ArrayList<Integer> a1 = new ArrayList<>();
        ArrayList<Integer> a11 = new ArrayList<>();
        int count1 = 0;
        for (int i = 0; i <al.size(); i++) {
            if(al.get(i) < al.get(size) - 1){
               a1.add(al.get(i));
               size2 = i;
            }

            if(al.get(i)  == al.get(size) ){
               count1+= al.get(size);
            }
            if(al.get(i) > al.get(size) + 1){
                if (flag == 0) {
                    size3 = i;
                }
               a11.add(al.get(i));
            }
        }

        ArrayList<Integer> a2 = new ArrayList<>();
        ArrayList<Integer> a22 = new ArrayList<>();
        int count2 = 0;
        for (int i = 0; i < al.size(); i++) {
            if(al.get(i) < al.get(size2) - 1){
               a2.add(al.get(i));
            }
            if(al.get(i)  == al.get(size2) ){
               count2+= al.get(size2);
            }
            if(al.get(i) > al.get(size2) + 1){
               a22.add(al.get(i));
            }
        }

        ArrayList<Integer> a3 = new ArrayList<>();
        ArrayList<Integer> a33 = new ArrayList<>();
        int count3 = 0;
        for (int i = 0; i < al.size(); i++) {
            if(al.get(i) < al.get(size3) - 1){
               a3.add(al.get(i));
            }
            if(al.get(i)  == al.get(size3) ){
               count3+=al.get(size3);
            }
            if(al.get(i) > al.get(size3) + 1){
               a33.add(al.get(i));
            }
        }

        int ans1 =count1 + count(a1)+count(a11) ;
        int ans2 = count2 + count(a2)+count(a22);
        int ans3 = count3 + count(a3)+count(a33);

        int max = Math.max(ans1, ans2);
        max = Math.max(max, ans3);

        return max;

    }}

}


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

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

        int n = in.nextInt();
         ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(in.nextInt());

        }
        Collections.sort(a);

        System.out.println("");
        System.out.println(count(a));

    }

    public static int count(ArrayList<Integer> al){
        if (al.size() == 1) {
            return al.get(0);
        }
        if (al.size() == 2) {
            if (al.get(0)==al.get(1)-1) {
                return al.get(1);
            }
            else if(al.get(1)==al.get(0)-1){
                return al.get(0);
            }
            else {
                return al.get(1)+al.get(0);
            }
        }
        if (al.isEmpty()) {
            return 0;
        }
        else{
            int flag = 0;
        int size2 = 0;
        int size3 = 0;
        int size = (al.size())/2;
        ArrayList<Integer> a1 = new ArrayList<>();
        ArrayList<Integer> a11 = new ArrayList<>();
        int count1 = 0;
        for (int i = 0; i <al.size(); i++) {
            if(al.get(i) < al.get(size) - 1){
               a1.add(al.get(i));
               size2 = i;
            }

            if(al.get(i)  == al.get(size) ){
               count1+= al.get(size);
            }
            if(al.get(i) > al.get(size) + 1){
                if (flag == 0) {
                    size3 = i;
                }
               a11.add(al.get(i));
            }
        }

        ArrayList<Integer> a2 = new ArrayList<>();
        ArrayList<Integer> a22 = new ArrayList<>();
        int count2 = 0;
        for (int i = 0; i < al.size(); i++) {
            if(al.get(i) < al.get(size2) - 1){
               a2.add(al.get(i));
            }
            if(al.get(i)  == al.get(size2) ){
               count2+= al.get(size2);
            }
            if(al.get(i) > al.get(size2) + 1){
               a22.add(al.get(i));
            }
        }

        ArrayList<Integer> a3 = new ArrayList<>();
        ArrayList<Integer> a33 = new ArrayList<>();
        int count3 = 0;
        for (int i = 0; i < al.size(); i++) {
            if(al.get(i) < al.get(size3) - 1){
               a3.add(al.get(i));
            }
            if(al.get(i)  == al.get(size3) ){
               count3+=al.get(size3);
            }
            if(al.get(i) > al.get(size3) + 1){
               a33.add(al.get(i));
            }
        }

        int ans1 =count1 + count(a1)+count(a11) ;
        int ans2 = count2 + count(a2)+count(a22);
        int ans3 = count3 + count(a3)+count(a33);

        int max = Math.max(ans1, ans2);
        max = Math.max(max, ans3);

        return max;

    }}

}


import java.util.Scanner;

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

        int n = in.nextInt();
        long[]a = new long[100001];
        long[] p = new long[100001];

        for (int i = 0; i < n; i++) {
           int m = in.nextInt();
           p[m] ++;

        }

        a[1]=p[1];
        for (int i = 2; i < 100001; i++) {
            a[i] = Math.max(a[i-1],a[i-2]+i*p[i]);
        }

        System.out.println(a[100000]);

    }
}


import java.util.Scanner;

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

        int n = in.nextInt();
        int[][] a = new int[2][100010];
        int[] p = new int[100010];
        for (int i = 0; i < n; i++) {

           p[in.nextInt()]++;

        }

        int max ;
        max = p[1];
        a[1][1]=p[1];
        a[0][1] = 0;
        for (int i = 2; i < 100010; i++) {
            a[1][i] = a[0][i-1]+i*p[i];
            a[0][i] = max;
                max = Math.max(a[0][i], a[1][i]);

        }

        System.out.println(max);

    }
}


import java.util.Scanner;

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

        int n = in.nextInt();
        Long[]a = new Long[100001];
        Long[] p = new Long[100001];
        for (int i = 0; i < n; i++) {

           p[in.nextInt()]++;

        }

        a[1]=p[1];
        for (int i = 2; i < 100001; i++) {
            a[i] = Math.max(a[i-1],a[i-2]+i*p[i]);

        }

        System.out.println(a[100000]);

    }
}