#include<stdio.h>

int main(void){
 	
  int N;
  int array[100000];
  long sum = 0;
  
  scanf("%d",&N);
  
  for(int i = 0;i < N;i ++){
   	scanf("%d",&array[i]); 
    if(array[i] % 3 != 0 || array[i] % 5 != 0){
     	sum += array[i]; 
    }
  }
  
  printf("%ld",sum);
  
  return 0;
}