#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long oo = 1e18;
const long long N = 3003;
ll dp[N][N], a[3003], b[3003], c[3003], n, ans = oo;
void minimize(ll &a, ll b){
if (a > b) a = b;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i ++)
cin >> a[i] >> b[i] >> c[i];
for (int i = 0; i <= n; i ++)
for (int j = 0; j <= n;j ++)
dp[i][j] = oo;
dp[0][0] = 0;
for (int i = 0; i <= n; i ++)
for (int j = 0; j <= n; j ++)
if (i + j <= n)
{
ll idx = i + j;
if (j)
minimize(dp[i][j], dp[i][j-1] + b[idx] - j + 1);
if (i)
minimize(dp[i][j], dp[i-1][j] + c[idx] - i + 1);
if (i + j == n)
minimize(ans, dp[i][j]);
}
cout << ans;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGxvbmcgbG9uZyBvbyA9IDFlMTg7CmNvbnN0IGxvbmcgbG9uZyBOID0gMzAwMzsKCmxsIGRwW05dW05dLCBhWzMwMDNdLCBiWzMwMDNdLCBjWzMwMDNdLCBuLCBhbnMgPSBvbzsKCnZvaWQgbWluaW1pemUobGwgJmEsIGxsIGIpewogICAgaWYgKGEgPiBiKSBhID0gYjsKfQoKCmludCBtYWluKCl7CgogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7IGNvdXQudGllKDApOwoKICAgIGNpbiA+PiBuOwoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkgKyspCiAgICAgICAgY2luID4+IGFbaV0gPj4gYltpXSA+PiBjW2ldOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDw9IG47IGkgKyspCiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPD0gbjtqICsrKQogICAgICAgICAgICAgICAgZHBbaV1bal0gPSBvbzsKCiAgICBkcFswXVswXSA9IDA7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gbjsgaSArKykKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8PSBuOyBqICsrKQogICAgICAgICAgICBpZiAoaSArIGogPD0gbikKICAgICAgICAgICAgewoKICAgICAgICAgICAgICAgIGxsIGlkeCA9IGkgKyBqOwoKICAgICAgICAgICAgICAgIGlmIChqKQogICAgICAgICAgICAgICAgICAgIG1pbmltaXplKGRwW2ldW2pdLCBkcFtpXVtqLTFdICsgYltpZHhdIC0gaiArIDEpOwogICAgICAgICAgICAgICAgaWYgKGkpCiAgICAgICAgICAgICAgICAgICAgbWluaW1pemUoZHBbaV1bal0sIGRwW2ktMV1bal0gKyBjW2lkeF0gLSBpICsgMSk7CgogICAgICAgICAgICAgICAgaWYgKGkgKyBqID09IG4pCiAgICAgICAgICAgICAgICAgICAgbWluaW1pemUoYW5zLCBkcFtpXVtqXSk7CiAgICAgICAgICAgIH0KCiAgICBjb3V0IDw8IGFuczsKCn0KCgo=