10
-405 -230 252 -393 -390 -259 97 163 81 -129
 3
10000 -10000 10000
 1
-10000
 20
-16 -23 29 44 -40 -50 -41 34 -38 30 -12 28 -44 -49 15 50 -28 38 -2 0

702.333333333333712
 10000.000000000016371
 0.000000000000000
 113.875000000000043

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class WeakAndPoor {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = in.readLine();
		StringTokenizer st = new StringTokenizer(line);

		final int n = Integer.parseInt(st.nextToken());

		line = in.readLine();
		st = new StringTokenizer(line);

		long[] a = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		in.close();

		Arrays.sort(a);

		long[] allProdPre = new long[n], allProdPost = new long[n];

		for (int i = 1; i < n; i++) {
			allProdPre[i] = allProdPre[i - 1] + (a[i] - a[i - 1]) * i;
		}

		for (int i = n - 2; i >= 0; i--) {
			allProdPost[i] = allProdPost[i + 1] + (a[i + 1] - a[i])
					* (n - 1 - i);
		}

		long min = Long.MAX_VALUE;
		
		int start = 0;
		// guess the location
		for (int i = 1; i < n; i++) {
			if (allProdPost[i] < allProdPre[i]) {
				start = i;
				break;
			}
		}
		
		double weakness = a[start];
		double diff =  allProdPre[start] - allProdPost[start];
		// diff >= 0 move down a little
		weakness -= diff / n;
		double poorness = allProdPre[start] - (a[start] - weakness)*start;
		System.out.println(poorness);
	}

}
