import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); long sum=0; int n=sc.nextInt(); int[]a=new int[n]; for (int i = 0; i < n; i++) { a[i]=sc.nextInt(); } for (int i = 0; i < n-1; i++) { for (int j =i+1; j < n; j++) { sum+=Math.abs(a[i]-a[j]); } } System.out.println(sum*2); //可能有向吧 要乘2 } }
0.0分
1 人评分