import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int t1,t2,t3,x,y,z,n; boolean wd=false;
		n = in.nextInt();
		t1 = in.nextInt();
		t2 = in.nextInt();
		t3 = in.nextInt();
		x = t1; y = x + t2; z = y + t3;
		for (int i = 0; i<n-1; i++){
					t1 = in.nextInt();
			t2 = in.nextInt();
			t3 = in.nextInt();
			if ((t1<0)||(t2<0)||(t3<0)) {System.out.printf("Ошибка"); wd=true; break;}
			else { x += t1; y = Math.max(x, y) + t2; z = Math.max(y, z) + t3;}
		}
		if (wd == false) {
			System.out.printf("Общее время обработки всех деталей = %d",z);}
	}
}