#include <iostream>
#include <algorithm>
#include <string.h>
#define ll long long
using namespace std;
ll a[100007];
ll b[100007];
bool c[100007];
bool d[100007];
int main()
{
for(int i=0;i<=100006;i++)
{
a[i]=0;
b[i]=0;
c[i]=0;
d[i]=0;
}
ll n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
b[a[i]]++;
}
ll temp=0;
for(int i=1;i<=100002;i+=2)
{
temp += (b[i]*i);
c[i]=1;
}
for(int i=2;i<=100002;i+=2)
{
if(b[i]*i > (b[i-1]*(i-1) + b[i+1]*(i+1)))
{
temp += (b[i]*i);
if(c[i-1]==1)
{
temp -= (b[i-1]*(i-1));
c[i-1]=0;
}
if(c[i+1]==1)
{
c[i+1]=0;
temp -= (b[i+1]*(i+1));
}
}
}
ll temp2=0;
for(int i=2;i<=100002;i+=2)
{
temp2 += (b[i]*i);
d[i]=1;
}
for(int i=1;i<=100002;i+=2)
{
if(b[i]*i > (b[i-1]*(i-1) + b[i+1]*(i+1)))
{
temp2 += (b[i]*i);
if(d[i-1]==1)
{
temp2 -= (b[i-1]*(i-1));
d[i-1]=0;
}
if(d[i+1]==1)
{
d[i+1]=0;
temp2 -= (b[i+1]*(i+1));
}
}
}
cout<<((temp>temp2)?temp:temp2);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmxsIGFbMTAwMDA3XTsKbGwgYlsxMDAwMDddOwpib29sIGNbMTAwMDA3XTsKYm9vbCBkWzEwMDAwN107CmludCBtYWluKCkKewogICAgZm9yKGludCBpPTA7aTw9MTAwMDA2O2krKykKICAgIHsKICAgICAgICBhW2ldPTA7CiAgICAgICAgYltpXT0wOwogICAgICAgIGNbaV09MDsKICAgICAgICBkW2ldPTA7CiAgICB9CiAgICBsbCBuOwogICAgY2luPj5uOwogICAgZm9yKGludCBpPTA7aTxuO2krKykKICAgIHsKICAgICAgICBjaW4+PmFbaV07CiAgICAgICAgYlthW2ldXSsrOwogICAgfQogICAgbGwgdGVtcD0wOwogICAgZm9yKGludCBpPTE7aTw9MTAwMDAyO2krPTIpCiAgICB7CiAgICAgICAgdGVtcCArPSAoYltpXSppKTsKICAgICAgICBjW2ldPTE7CiAgICB9CiAgICBmb3IoaW50IGk9MjtpPD0xMDAwMDI7aSs9MikKICAgIHsKICAgICAgICBpZihiW2ldKmkgPiAoYltpLTFdKihpLTEpICsgYltpKzFdKihpKzEpKSkKICAgICAgICB7CiAgICAgICAgICAgIHRlbXAgKz0gKGJbaV0qaSk7CiAgICAgICAgICAgIGlmKGNbaS0xXT09MSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdGVtcCAtPSAoYltpLTFdKihpLTEpKTsKICAgICAgICAgICAgICAgIGNbaS0xXT0wOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmKGNbaSsxXT09MSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY1tpKzFdPTA7CiAgICAgICAgICAgICAgICB0ZW1wIC09IChiW2krMV0qKGkrMSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIAogICAgICAgIH0KICAgIH0KICAgIAogICAgCiAgICAKICAgIAogICAgCiAgICBsbCB0ZW1wMj0wOwogICAgCiAgICBmb3IoaW50IGk9MjtpPD0xMDAwMDI7aSs9MikKICAgIHsKICAgICAgICB0ZW1wMiArPSAoYltpXSppKTsKICAgICAgICBkW2ldPTE7CiAgICB9CiAgICBmb3IoaW50IGk9MTtpPD0xMDAwMDI7aSs9MikKICAgIHsKICAgICAgICBpZihiW2ldKmkgPiAoYltpLTFdKihpLTEpICsgYltpKzFdKihpKzEpKSkKICAgICAgICB7CiAgICAgICAgICAgIHRlbXAyICs9IChiW2ldKmkpOwogICAgICAgICAgICBpZihkW2ktMV09PTEpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHRlbXAyIC09IChiW2ktMV0qKGktMSkpOwogICAgICAgICAgICAgICAgZFtpLTFdPTA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoZFtpKzFdPT0xKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBkW2krMV09MDsKICAgICAgICAgICAgICAgIHRlbXAyIC09IChiW2krMV0qKGkrMSkpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIGNvdXQ8PCgodGVtcD50ZW1wMik/dGVtcDp0ZW1wMik7Cgp9