public static void main(String[] args) throws FileNotFoundException {

		File f = new File("src/jobs.txt");
		Scanner sr = new Scanner(f);
		sr.next();
		int i = 0;
		for (i = 0; i < 10000; i++) {
			jobs[i][0] = sr.nextInt();
			jobs[i][1] = sr.nextInt();
			jobs[i][2] = jobs[i][0] / jobs[i][1];
		}
		Sortingbydifference();
		// Sortingbywieghtdividedbylength();
		for (i = 0; i < 1000; i++) {
			System.out.print(jobs[i][0] + " ");
			System.out.print(jobs[i][1] + " ");
			System.out.print(jobs[i][2] + " ");
			System.out.print("\n");
		}
		int time = 0;
		long wieghtedtime = 0;
		for (i = 0; i < 10000; i++) {

			time = (int) ((int) time + jobs[i][1]);
			wieghtedtime = (long) ((long) wieghtedtime + time * jobs[i][0]);

		}
		System.out.print(wieghtedtime);

	}