#include using namespace std; using ll = long long; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int s = 0; for (int i = 0; i < n; i++) { if (i == 0 || a[i - 1] + 1 != a[i]) s += a[i]; } cout << s << endl; return 0; }