import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.io.PrintWriter import java.lang.StringBuilder import java.util.* import kotlin.math.* fun main() { var n = one_To_Int() var a = list_To_Int() var p = a.toSortedSet() var res = 0 for (i in 0..n-1){ if (!p.contains(a[i] - 1)) { res += a[i] } } println(res) } var mod99:Long = 998244353 var mod10:Long = 1000000007 var modt = 1000000000000L val reader = System.`in`.bufferedReader() var inf = 1000000002L fun init_String_SortedList():SortedSet{ return init_String_List().toSortedSet() } fun init_Int_SortedList():SortedSet{ return init_Int_List().toSortedSet() } fun init_Long_SortedList():SortedSet{ return init_Long_List().toSortedSet() } fun mod_pow(x:Long, n:Long, p: Long): Long { var ans = 1L var X: Long = x var N: Long = n while (N >= 1L) { if (N % 2 == 1L) { ans *= X ans = ans % p } X *= X X = X % p N = N / 2 } return ans } //fun pow(x:BigInteger, n:BigInteger):BigInteger{ // var ans = 1.toBigInteger() // var X: BigInteger = x // var N:BigInteger = n // while (N >= 1.toBigInteger()) { // if (N % 2 == 1.toBigInteger()) { // ans *= X // // } // X *= X // N = N / 2.toBigInteger() // } // return ans //} fun input():String{ return reader.readLine() } fun init_Long_List():MutableList{ var a = MutableList(0) { 0 } return a } fun init_String_List():MutableList{ var a = MutableList(0) { "" } return a } fun init_Int_List():MutableList{ var a = MutableList(0) { 0 } return a } fun list_To_Int():MutableList{ return input().split(" ").map{it.toInt()}.toMutableList() } fun list_To_Long():MutableList{ return input().split(" ").map{it.toLong()}.toMutableList() } fun one_To_Int():Int{ return input().toInt() } fun one_To_Long():Long { return input().toLong() } fun one_To_Double():Double { return input().toDouble() } //fun deque():ArrayDeque{ // var queue:ArrayDeque = ArrayDeque() // return queue //} fun merge(A:MutableList,left:Int, mid:Int, right:Int) { var n1 = mid - left; var n2 = right - mid; var L = MutableList(n1 + 1) { 0 } var R = MutableList(n2 + 1) { 0 } for (i in 0..n1 - 1) { L[i] = A[left + i] } for (i in 0..n2 - 1){ R[i] = A[mid + i] } L[n1] = inf R[n2] = inf var i = 0 var j = 0 for (k in left..right - 1) { if (L[i] <= R[j]) { A[k] = L[i] i = i + 1 } else { A[k] = R[j] j = j + 1 } } } fun make_divisor(n:Long):MutableList{ var res = init_Long_List() var i = 1L while (i * i <= n){ if (n % i == 0L){ res.add(i) if (i*i != n){ res.add(n/i) } } i += 1 } res.sort() res.add(n) return res } fun Sort(A:MutableList,left:Int, right:Int){ if (left+1 < right) { var mid = (left + right) / 2; Sort(A, left, mid) Sort(A, mid, right) merge(A, left, mid, right) } } fun gcd(a :Int ,b:Int):Int{ if (a % b == 0){ return b }else{ return gcd(b,a%b) } }