#include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N); for (int &i: A) cin >> i; sort(A.begin(), A.end()); int ans = A[0]; for (int i = 1; i < N; i++) { if (A[i] - A[i - 1] != 1) ans += A[i]; } cout << ans << endl; return 0; }