import std.stdio, std.string,std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.container, std.datetime;

void main() {
  auto N = readln.chomp.to!int;
  auto a = readln.split.to!(int[]);
  a.map!(x => (x-(a.sum.to!double/N).round)^^2).array.sum.writeln;
}
