https://www.acmicpc.net/problem/1149
"""
1. 아이디어
조건에 맞는 범위 내에서 비용을 더해주고 마지막에 최솟값을 출력해주면 된다.
2. 시간복잡도
O(n)정도 되지 않을까? 정확히 따지면 for 연산은 n-1회 min()은 2개의 비용만 따지니깐
2n-2 = O(n) 이렇게 되나..
"""
from sys import stdin
input = stdin.readline
n = int(input())
costs = [ list(map(int, input().split())) for _ in range(n) ]
for i in range(1, n):
costs[i][0] += min(costs[i-1][1], costs[i-1][2])
costs[i][1] += min(costs[i-1][0], costs[i-1][2])
costs[i][2] += min(costs[i-1][0], costs[i-1][1])
print(min(costs[n-1]))
DP문제를 조금이라도 풀어 봤으면 쉽게 풀법한 문제인데 DP문제를 모르면 좀 해맬것 같은 문제이다.