#!/usr/bin/env python # coding=utf-8 # Python使用的是3.4.3,缩进可以使用tab、4个空格或2个空格,但是只能任选其中一种,不能多种混用 n = int(input()) lines = [] for i in range(0, n): line = list(map(int, input().split())) # read_list = [int(i) for i in input().split()] lines.append(line) ans = 0 if n != 0: b = lines[0][1] a = lines[0][0]+ lines[0][2] for i in range(1, n): num = lines[i] a_buf = a b_buf = b a = min(a_buf + num[0], b_buf + num[2] + num[0]) b = min(b_buf + num[1], a_buf + num[2] + num[1]) ans = min(a, b) print(ans , "\n")