import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        // 消耗空行
        in.nextLine();
        // 大小特别大不能创造这么大的数组,我们就维护一个hash表,若这个数存在就代表已经改过数据
        // 若没有改过就代表为0
        long res = 0L;
        Map<Long,Long> maps = new HashMap<>();
        for(int i = 1 ; i <= n ; i++){
            String[] parts=in.nextLine().split(" ");
            long x = Long.parseUnsignedLong(parts[0]);
            long y = Long.parseUnsignedLong(parts[1]);
            long ans=maps.getOrDefault(x,0L);
            maps.put(x,y);
            res = res + i*ans;
        }
        System.out.println(Long.toUnsignedString(res));
    }
}