#!/usr/bin/env python3

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

intervals.sort(key=lambda x: x[1], reverse=True)
compressed_time = list(set(compressed_time))
compressed_time.sort()
compressed_time_map = dict()
for i, t in enumerate(compressed_time):
    compressed_time_map[t] = i

total = 0
used = [False] * len(compressed_time)
for i in range(N):
    s, e, a = intervals[i][0], intervals[i][1], intervals[i][2]
    ms, me = compressed_time_map[s], compressed_time_map[e]

    if used[ms] or used[me]:
        continue

    total += a
    for j in range(ms, me + 1):
        used[j] = True
print(total) 
