import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    }
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    } main {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] x = new int[n]; x new int[n] n for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        } int i =0; int i =0; i 0 i<n i n i++ i++ i {
            x[i] = sc.nextInt();
        } {
            x[i] = sc.nextInt();
        } x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc int minX = Arrays.stream(x).min().getAsInt(); minX Arrays.stream(x).min().getAsInt() Arrays.stream(x).min().getAsInt Arrays.stream(x).min() Arrays.stream(x).min Arrays.stream(x) Arrays.stream Arrays x int maxX = Arrays.stream(x).max().getAsInt(); maxX Arrays.stream(x).max().getAsInt() Arrays.stream(x).max().getAsInt Arrays.stream(x).max() Arrays.stream(x).max Arrays.stream(x) Arrays.stream Arrays x int minValue = Integer.MAX_VALUE; minValue Integer.MAX_VALUE Integer Integer.MAX_VALUE int[] power = new int[n]; power new int[n] n for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        } int i = minX; int i = minX; i minX i <= maxX i maxX i++ i++ i { //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        } { //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        } for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            } int j = 0; int j = 0; j 0 j<x.length j x.length x x.length j++ j++ j { //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            } { //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            } power[j] = (x[j]-i)*(x[j]-i) power[j] power j (x[j]-i)*(x[j]-i) (x[j]-i) x[j] x j i (x[j]-i) x[j] x j i minValue = Math.min(minValue, Arrays.stream(power).sum()) minValue Math.min(minValue, Arrays.stream(power).sum()) Math.min Math minValue Arrays.stream(power).sum() Arrays.stream(power).sum Arrays.stream(power) Arrays.stream Arrays power System.out.println(minValue) System.out.println System.out System System.out minValue String[] args args public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    }
} public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    }
}