object Main{
  def main(args : Array[String]): Unit ={
    // do something
    val k : SubMain = new SubMain
    k.solve
  }
}

class SubMain{
  var n : Int = 0
  var as : Array[Int] = Array.empty
  def getN: Unit ={
    n = scala.io.StdIn.readLine().toInt
  }
  def getDatas: Unit ={
    as = scala.io.StdIn.readLine().split(' ').map(_.toInt)
  }
  def subsolve: Int ={
    val s : Int = as.sum
    val tmpAs = as.map(i => math.abs(i * n - s))
    tmpAs.zipWithIndex.min._2
  }
  def solve: Unit ={
    getN
    getDatas
    val res = subsolve
    println(res)
  }
}