#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);
  bool RC = false;
  int sum = 0;
  int cc = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    cin >> B[i];
    cin >> C[i];
  }
  for (int i = 1; i <= A.size(); i++) {
    sum += B[A[i] - 1];
    if (A[i] + 1 == A[i + 1]) {
      RC = true;
      sum += B[A[i] - 1];
      cc += C[i];
      ans = sum + cc;
    }
  }
  if (RC) {
    cout << ans << endl;
  } else {
    cout << sum << endl;
  }
}
