#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n - 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i + 1];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += b[a[i]];
    if (i > 0 && a[i] == a[i - 1] + 1) {
      sum += c[a[i]];
    }
  }
  cout << sum << endl;
}
