void addEff(int val1[], int val2[], int val3[], int pos1[], int pos2[], int pos3[], int k1, int k2){
//access to each element in pos1[] and check if it has same position in pos2[]
//if pos2[]has smaller value of position, add val2[] first before add val1[]
int count=0;
int i=0;
int j=0;
while (i<k1){
while (pos2[j]<=pos1[i]){
if (pos2[j]<=pos1[i]){
val3[count]+=val2[j];
pos3[count]=pos2[j];
j++;
break;
}
val3[count]+=val2[j];
pos3[count]=pos2[j];
count++;
j++;
}
val3[count]+=val1[i];
pos3[count]=pos1[i];
count++;
i++;
}