#include <iostream>

using namespace std;

const int MAXN = 100 + 10;
int arr[MAXN];

int main () {
	int a;
	cin >> a;
	int sum = 0;
	for (int i = 0; i < 5; i++){
		cin >> arr[i];
		if (arr[i] < a){
			sum += arr[i];
		}
	}
	cout << sum << endl;
	return 0;
}