// No.1686 Geschenkt package main import ( "fmt" "sort" ) func main() { var n int fmt.Scan(&n) a := make([]int, n) for i := 0; i < n; i++ { fmt.Scan(&a[i]) } sort.Ints(a) ans := a[0] for j := len(a) - 1; j > 0; j-- { if a[j] != a[j-1]+1 { ans += a[j] } } fmt.Println(ans) }