// Arup Guha
// 5/4/2018
// Solution to 2018 March USACO Gold Problem: Out of Sorts

import java.util.*;
import java.io.*;

public class sort_gold {

	public static int n;
	public static item[] list;

	public static void main(String[] args) throws Exception {

		BufferedReader stdin = new BufferedReader(new FileReader("sort.in"));
		n = Integer.parseInt(stdin.readLine().trim());
		list = new item[n];

		// Read in the numbers and sort.
		for (int i=0; i<n; i++)
			list[i] = new item(Integer.parseInt(stdin.readLine().trim()), i+1);
		Arrays.sort(list);

		long res = 1;
		bit mybit = new bit(n);

		// Sweep through relatively sorted list.
		for (int i=0; i<n-1; i++) {

			// Add the current item.
			mybit.add(list[i].idx, 1);

			// See how many items have to move from <= idx i to > idx i
			long moveRight = mybit.above(i+1);

			// And how many have to move from > idx i to <= idx i.
			long moveLeft = (i+1) - mybit.sum(i+1);

			// Our answer must be at least as big the larger of these two.
			res = Math.max(res, Math.max(moveLeft, moveRight));
		}

		// Write result.
		PrintWriter out = new PrintWriter(new FileWriter("sort.out"));
		out.println(res);
		out.close();
		stdin.close();
	}
}

class bit {

	public long[] cumfreq;

	// Do indexes 1 to n.
	public bit(int n) {

		int size = 1;
		while (size < n) size <<= 1;
		n = size;

		cumfreq = new long[n+1];
	}

	// Uses 1 based indexing.
	public void add(int index, long value) {
		while (index < cumfreq.length) {
			cumfreq[index] += value;
			index += Integer.lowestOneBit(index);
		}
	}

	// Returns the sum of everything upto index.
	public long sum(int index) {
		long ans = 0;
		while (index > 0) {
			ans += cumfreq[index];
			index -= (Integer.lowestOneBit(index));
		}
		return ans;
	}

	// Use 1 based indexing.
	public long sum(int low, int high) {
		return sum(high) - sum(low-1);
	}

	// Return the total number of items in the BIT.
	public long all() {
		return sum(cumfreq.length-1);
	}

	// Return the total number of items in the BIT at or above index.
	public long above(int index) {
		return all() - sum(index);
	}
}

class item implements Comparable<item> {

	public int val;
	public int idx;

	public item(int v, int i) {
		val = v;
		idx = i;
	}

	public int compareTo(item other) {
		if (this.val != other.val)
			return this.val - other.val;
		return this.idx - other.idx;
	}
}