#include <iostream>
using namespace std;

int main() {
    int a, sum = 0, n;
    cin >> a;
    for(int i = 0;i < 5; i++){
        cin >> n;
        if(n < a) sum += n;
    }
    cout << sum;

    return 0;
}