#include<cstdio>
int main(){
	int a, s[5];
	while (scanf("%d %d %d %d %d %d", &a, &s[0], &s[1], &s[2], &s[3], &s[4]) != EOF){
		int sum=0;
		for (int i = 0; i < 5; i++){
			if (s[i] < a){
				sum = sum + s[i];
			}
		}
		printf("%d\n", sum);
	}
}