#!/usr/bin/env python3

import bisect

N = int(input())
intervals = []
for i in range(N):
    s, e, a = map(int, input().split())
    intervals.append([s, e, a])

intervals.sort(key=lambda x: x[1])
intervals_end = [intervals[i][1] for i in range(N)]

p = []
for i in range(N):
    start = intervals[i][0]
    insert_index = bisect.bisect_right(intervals_end, start, hi=i)
    if insert_index == 0:
        p.append(-1)
    else:
        p.append(insert_index - 1)

opt = [0 for _ in range(N)]
for i in range(N):
    a = intervals[i][2] if p[i] == -1 else intervals[i][2] + opt[p[i]]
    b = 0 if i == 0 else opt[i-1]
    opt[i] = max(a, b)

print(opt[N-1])
