int main() { int n, m, t; cin >> n >> m >> t; for (int i = 1; i <= n; i++) cin >> s[i]; for (int i = 1; i <= m; i++) cin >> q[i].a >> q[i].b >> q[i].c; sort(q + 1, q + m + 1, cmp); for (int i = 1; i <= t; i++) dp[i] = -INF; for (int i = 1; i <= m; i++) for (int j = t; j >= q[i].c; j--) dp[j] = max(dp[j], dp[j - q[i].c] + q[i].b - j * s[q[i].a]); for (int i = 1; i <= t; i++) res = max(res, dp[i]); cout << res << '\n'; return0; }