#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[20], b[50], c[50];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int ans = 0;
  int tmp = a[0];
  for (int i = 0; i < n; i++) {
    ans += b[a[i] - 1];
    if (tmp + 1 == a[i]) {
      ans += c[tmp - 1];
    }
    tmp = a[i];
  }
  cout << ans;
  return 0;
}
