#include <iostream>

using namespace std;

const int N = 10;
int a[N];

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

	return 0;
}