output_description: Print the necessary number of candies in total.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
attempt: #!/usr/bin/python
  # -*- coding: UTF-8 -*-
  
  import sys
  
  
  def get_ints():
      return map(int, sys.stdin.readline().strip().split())
  
  
  def _main():
      input()
      an = list(get_ints())
  
      t = 0
      old = 1000000000
      while 1:
          ans = sq(t, an)
          g = sq(t + 1, an) - ans
          t -= g / abs(g)
          if old > ans:
              old = ans
          else:
              break
      print(int(old))
  
  
  def sq(t, an):
      ans = 0
      for ai in an:
          ans += pow(ai - t, 2)
      return ans
  
  
  if __name__ == "__main__":
      _main()
  
problem_description: Statement
  
  There are N children in AtCoder Kindergarten. Mr. Evi will arrange the
  children in a line, then give 1 candy to the first child in the line, 2
  candies to the second child, ..., N candies to the N-th child. How many
  candies will be necessary in total?
samples: [{"input": "3", "output": "6\n    \n\nThe answer is 1+2+3=6.\n\n* * *"}, {"input": "10", "output": "55\n    \n\nThe sum of the integers from 1 to 10 is 55.\n\n* * *"}, {"input": "1", "output": "1\n    \n\nOnly one child. The answer is 1 in this case."}]