import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		int x[] = new int[n];
		for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int min = sum / n;
		double ave = (double) sum / (double) n;
		min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		}
		sc.close();
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		int x[] = new int[n];
		for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int min = sum / n;
		double ave = (double) sum / (double) n;
		min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		}
		sc.close();
		System.out.println(ans);
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		int x[] = new int[n];
		for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int min = sum / n;
		double ave = (double) sum / (double) n;
		min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		}
		sc.close();
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		int x[] = new int[n];
		for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int min = sum / n;
		double ave = (double) sum / (double) n;
		min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		}
		sc.close();
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt() n sc.nextInt() sc.nextInt sc sum = 0; sum 0 int x[] = new int[n]; x new int[n] n for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		} int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
			x[i] = sc.nextInt();
			sum += x[i];
		} {
			x[i] = sc.nextInt();
			sum += x[i];
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc sum += x[i] sum x[i] x i int min = sum / n; min sum / n sum n double ave = (double) sum / (double) n; ave (double) sum / (double) n (double) sum (double) n min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1) min (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1) Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) Math.abs(ave - (double)min) Math.abs Math ave - (double)min ave (double)min Math.abs(ave - (double)(min + 1)) Math.abs Math ave - (double)(min + 1) ave (double)(min + 1) min 1 min min + 1 min 1 int ans = 0; ans 0 for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		} int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
			ans += (x[i] - min) * (x[i] - min);
		} {
			ans += (x[i] - min) * (x[i] - min);
		} ans += (x[i] - min) * (x[i] - min) ans (x[i] - min) * (x[i] - min) (x[i] - min) x[i] x i min (x[i] - min) x[i] x i min sc.close() sc.close sc System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		int x[] = new int[n];
		for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int min = sum / n;
		double ave = (double) sum / (double) n;
		min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		}
		sc.close();
		System.out.println(ans);
	}
} public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		int x[] = new int[n];
		for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int min = sum / n;
		double ave = (double) sum / (double) n;
		min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		}
		sc.close();
		System.out.println(ans);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), sum = 0;
		int x[] = new int[n];
		for(int i = 0; i < n; ++i){
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int min = sum / n;
		double ave = (double) sum / (double) n;
		min = (Math.abs(ave - (double)min) <= Math.abs(ave - (double)(min + 1)) ? min : min + 1);
		int ans = 0;
		for(int i = 0; i < n; ++i){
			ans += (x[i] - min) * (x[i] - min);
		}
		sc.close();
		System.out.println(ans);
	}
}
