#-*-coding:utf-8-*-
import sys
import math
input=sys.stdin.readline

def main():
    maps=[]
    n = int(input())
    maps=list(map(int,input().split()))
    ans=0
    answers=[]

    for i in range(1,101):
        for data in maps:
            ans+=abs(i-data)**2
        answers.append(ans)
        ans=0
    print(min(answers))

if __name__=="__main__":
    main() import sys sys import math math input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    maps=[]
    n = int(input())
    maps=list(map(int,input().split()))
    ans=0
    answers=[]

    for i in range(1,101):
        for data in maps:
            ans+=abs(i-data)**2
        answers.append(ans)
        ans=0
    print(min(answers)) main maps=[] maps [] n = int(input()) n int(input()) int input() input maps=list(map(int,input().split())) maps list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans=0 ans 0 answers=[] answers [] for i in range(1,101):
        for data in maps:
            ans+=abs(i-data)**2
        answers.append(ans)
        ans=0
     i range(1,101) range 1 101 for data in maps:
            ans+=abs(i-data)**2
         data maps ans+=abs(i-data)**2 ans abs(i-data)**2 abs(i-data) abs i-data i data 2 answers.append(ans) answers.append answers append ans ans=0 ans 0 print(min(answers)) print min(answers) min answers if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main input=sys.stdin.readline sys.stdin.readline input def main():
    maps=[]
    n = int(input())
    maps=list(map(int,input().split()))
    ans=0
    answers=[]

    for i in range(1,101):
        for data in maps:
            ans+=abs(i-data)**2
        answers.append(ans)
        ans=0
    print(min(answers)) def main():
    maps=[]
    n = int(input())
    maps=list(map(int,input().split()))
    ans=0
    answers=[]

    for i in range(1,101):
        for data in maps:
            ans+=abs(i-data)**2
        answers.append(ans)
        ans=0
    print(min(answers)) main
#-*-coding:utf-8-*-
import sys
import math
input=sys.stdin.readline

def main():
    maps=[]
    n = int(input())
    maps=list(map(int,input().split()))
    ans=0
    answers=[]

    for i in range(1,101):
        for data in maps:
            ans+=abs(i-data)**2
        answers.append(ans)
        ans=0
    print(min(answers))

if __name__=="__main__":
    main()