import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
{
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
);} }
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkJaW50IHQxLHQyLHQzLHgseSx6LG47IGJvb2xlYW4gd2Q9ZmFsc2U7CgkJbiA9IGluLm5leHRJbnQoKTsKCQl0MSA9IGluLm5leHRJbnQoKTsKCQl0MiA9IGluLm5leHRJbnQoKTsKCQl0MyA9IGluLm5leHRJbnQoKTsKCQl4ID0gdDE7IHkgPSB4ICsgdDI7IHogPSB5ICsgdDM7CgkJZm9yIChpbnQgaSA9IDA7IGk8bi0xOyBpKyspewoJCQkJCXQxID0gaW4ubmV4dEludCgpOwoJCQl0MiA9IGluLm5leHRJbnQoKTsKCQkJdDMgPSBpbi5uZXh0SW50KCk7CgkJCWlmICgodDE8MCl8fCh0MjwwKXx8KHQzPDApKSB7U3lzdGVtLm91dC5wcmludGYoItCe0YjQuNCx0LrQsCIpOyB3ZD10cnVlOyBicmVhazt9CgkJCWVsc2UgeyB4ICs9IHQxOyB5ID0gTWF0aC5tYXgoeCwgeSkgKyB0MjsgeiA9IE1hdGgubWF4KHksIHopICsgdDM7fQoJCX0KCQlpZiAod2QgPT0gZmFsc2UpIHsKCQkJU3lzdGVtLm91dC5wcmludGYoItCe0LHRidC10LUg0LLRgNC10LzRjyDQvtCx0YDQsNCx0L7RgtC60Lgg0LLRgdC10YUg0LTQtdGC0LDQu9C10LkgPSAlZCIseik7fQoJfQp9