import java.util.*; public class 满意度 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[][] arr = new long[n][2]; for (int i = 0; i < n; i++) { arr[i][0] = in.nextLong(); arr[i][1] = in.nextLong(); } Arrays.sort(arr, (e1, e2) -> (int) ((e2[0]-e2[1]) - (e1[0]-e1[1]))); long count = 0; for (int i = 0; i < arr.length; i++) { count+=( arr[i][0]*(i)+arr[i][1]*(n-i-1)); } System.out.println(count); } }