import java.io.*;
import java.util.*;
import java.util.zip.Checksum;

public class semipal_av_n3 {

	FastScanner in;
	PrintWriter out;
	
	final int[] mapTo = new int[26], mapFrom = new int[26];

	void solve() {
		int n = in.nextInt();
		String s = in.nextToken();
		String sR = new StringBuilder(s).reverse().toString();
		boolean[][] can = new boolean[n][n];

		for (int i = 0; i < n; i++) {
			can[i][i] = true;
		}
		for (int i = 0; i < n - 1; i++) {
			can[i][i + 1] = true;
		}

		for (int len = 3; len <= n; len++) {
			for (int i = 0, j = len - 1; j < n; i++, j++) {
				int middleL = i + len / 2 - 1, middleR = j - len / 2 + 1;
				if (!can[i][middleL] || !can[middleR][j]) {
					continue;
				}

				int checkLength = (len + 1) / 2;

				if (areEquivalent(s, i, sR, n - j - 1, checkLength)) {
					can[i][j] = true;
				}
			}
		}

		int bestLen = 1, bestI = 0;
		for (int len = 2; len <= n; len++) {
			for (int i = 0; i + len <= n; i++) {
				if (can[i][i + len - 1]) {
					bestLen = len;
					bestI = i;
				}
			}
		}

		out.println(s.substring(bestI, bestI + bestLen));
	}

	private boolean areEquivalent(String s1, int from1, String s2, int from2, int length) {

		Arrays.fill(mapTo, -1);
		Arrays.fill(mapFrom, -1);

		for (int i = 0; i < length; i++) {
			int first = s1.charAt(i + from1) - 'a', second = s2.charAt(i + from2) - 'a';
			if (mapTo[first] == -1 && mapFrom[second] == -1) {
				mapTo[first] = second;
				mapFrom[second] = first;
			} else if (mapTo[first] == -1 || mapFrom[second] == -1) {
				return false;
			} else {
				if (mapTo[first] != second || mapFrom[second] != first) {
					return false;
				}
			}
		}
		return true;
	}

	void run() {
		try {
			in = new FastScanner("semipal.in");
			out = new PrintWriter("semipal.out");
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String file) {
			try {
				br = new BufferedReader(new FileReader(file));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

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

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

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

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

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