fun main(args:Array<String>) {
 val N = readLine()!!.toInt()
 val AB= (1..N).map {
    val arr=readLine()!!.split(" ").map(String::toLong)
    Pair(arr[0],arr[1])
  }.sortedBy{ it.first}
  // println(AB)
(  1.until(N).map { 
    AB[it].first - AB[it-1].first
}.fold(0L) { sum,ele -> sum+ele}+AB[N -1 ].second + AB[0].first  ).let { 
    println(it)
  }
}