# include <iostream>
# include <algorithm>
using namespace std;

const int MAX=1000003;
int a[MAX];
bool trap[MAX];
int n;
int ans=0;

void trapped(int x, int place)
{
    for(int i=place;i>=1;i++)
    if(a[i]<x and trap[i]==0)
    {
        ans=ans-a[i];
        trap[i]=1;
        trapped(a[i],i);
    }
    return ;
}

int main()
{

    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        ans=ans+a[i];
    }

    //sort(a,a+(n+1));

    //for(int i=n;i>=1;i++)
      //trapped(a[i],i);

    cout<<ans<<endl;
    return 0;
}
