#include<bits/stdc++.h>
using namespace std;

long long n;
long long solve[5];
int main()
{
    while( ~scanf("%lld",&n) )
    {
        for(int i=0; i<5; ++i)
        {
            scanf("%lld",&solve[i] );
        }
        long long sum=0;

        for(int i=0; i<5; ++i)
        {
            if( solve[i]<n )
            {
                sum+=solve[i];
            }
        }

        printf("%lld\n",sum);
    }

    return 0;
 }