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

public class semipal_av_hash {

	FastScanner in;
	PrintWriter out;

	final int p = 31;

	long[][] getHash(String s) {
		int[] num = new int[26];
		int n = s.length();
		long[][] res = new long[n][];
		for (int i = 0; i < n; i++) {
			res[i] = new long[n - i];
			Arrays.fill(num, -1);
			long hash = 0;
			int nums = 0;
			for (int j = i; j < n; j++) {
				int c = s.charAt(j) - 'a';
				if (num[c] == -1) {
					nums++;
					num[c] = nums;
				}
				hash = hash * p + num[c];
				res[i][j - i] = hash;
			}
		}
		return res;
	}

	long[][] getReverseHash(String s) {
		int[] num = new int[26];
		int n = s.length();
		long[][] res = new long[n][];
		for (int i = 0; i < n; i++) {
			res[i] = new long[n - i];
		}
		for (int j = n - 1; j >= 0; j--) {
			Arrays.fill(num, -1);
			long hash = 0;
			int nums = 0;
			for (int i = j; i >= 0; i--) {
				int c = s.charAt(i) - 'a';
				if (num[c] == -1) {
					nums++;
					num[c] = nums;
				}
				hash = hash * p + num[c];
				res[i][j - i] = hash;
			}
		}
		return res;
	}

	void solve() {
		int n = in.nextInt();
		String s = in.nextToken();
		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;
		}

		long[][] hash = getHash(s), hashRev = getReverseHash(s);

		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;
				}

				long hash1 = hash[i][(len - 1) / 2], hash2 = hashRev[j
						- (len - 1) / 2][(len - 1) / 2];
				if (hash1 == hash2) {
					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));
	}

	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_hash().run();
	}
}
