object Main{
  
    val sc = new java.util.Scanner(System.in);
    val n = sc.nextInt();
    val a = Array.ofDim[Int](n);
    for(i <- 0 until n){
      a(i) = sc.nextInt();
    }
    println(math.abs(a.sorted.foldRight(0)(_-_)));
}