// Arup Guha
// 5/8/2018
// Solution to USACO 2015 US Open Bronze Problem: Trapped in the Haybales

import java.util.*;
import java.io.*;

public class trapped {

	public static int n;
	public static bale[] list;

	public static Boolean[][] memo;

	public static void main(String[] args) throws Exception {

		// Read in data, sort by position.
		Scanner stdin = new Scanner(new File("trapped.in"));
		n = stdin.nextInt();
		list = new bale[n];
		for (int i=0; i<n; i++) {
			int size = stdin.nextInt();
			int pos = stdin.nextInt();
			list[i] = new bale(pos, size);
		}
		Arrays.sort(list);

		// memo[i][j] will store result of if you can get out of [i..all open..j].
		memo = new Boolean[n][n];
		for (int i=0; i<n; i++) Arrays.fill(memo[i], null);

		int ans = 0;
		for (int i=0; i<n-1; i++) {
			boolean res = go(i, i+1);
			if (res == false)
				ans += (list[i+1].pos - list[i].pos);
		}

		// Write result.
		PrintWriter out = new PrintWriter(new FileWriter("trapped.out"));
		out.println(ans);
		out.close();
		stdin.close();
	}

	// Returns true
	public static boolean go(int a, int b) {

		// We did this before.
		if (memo[a][b] != null) return memo[a][b];

		// Amount of speed we can build up.
		int speed = list[b].pos - list[a].pos;

		// Base cases for getting out!
		if (a == 0 && speed > list[a].size) return memo[a][b] = true;
		if (b == n-1 && speed > list[b].size) return memo[a][b] = true;

		// Try breaking both walls!
		boolean res = false;
		if (speed > list[a].size) res = res || go(a-1, b);
		if (speed > list[b].size) res = res || go(a, b+1);

		// Store and return.
		return memo[a][b] = res;
	}
}

class bale implements Comparable<bale> {

	public int pos;
	public int size;

	public bale(int p, int s) {
		pos = p;
		size = s;
	}

	public int compareTo(bale other) {
		return this.pos - other.pos;
	}
}