# PATB-1012 数字分类 最后一个测试点问题

#include "stdio.h"
#include <iostream>
using namespace std;

int main() {
int arr[1005] = { 0 };
int len = 0;
int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, tot_a4 = 0;

bool flag = false;  //false加 true减
bool flag_a2 = false;  //判断a2是否存在计算

cin >> len;
for (int i = 0; i < len; i++) {
cin >> arr[i];
}
for (int i = 0; i < len; i++) {
if (arr[i] % 5 == 0) {
if (arr[i] % 2 == 0) {
a1 += arr[i];
//cout << a1 << " " << arr[i] << endl;
}
}
if (arr[i] % 5 == 1) {   //该点注意，这里可能结果和a2为0
flag_a2 = true;   //在进入该函数内立即更新a2的标志，证明a2是有效的
if (flag == false) a2 += arr[i];
else a2 -= arr[i];
flag = !flag;
}
if (arr[i] % 5 == 2) {
a3++;
}
if (arr[i] % 5 == 3) {
a4 += arr[i];
tot_a4++;
}
if (arr[i] % 5 == 4) {
if (arr[i] > a5) a5 = arr[i];
}
}
if (a1 == 0) cout << "N";
else cout << a1;
if (flag_a2 == false) cout << " N";  //用a2的标志来判断输出N还是a2数据
else cout << " " << a2;
if (a3 == 0) cout << " N";
else cout << " " << a3;
if (tot_a4 == 0) cout << " N";
else printf(" %.1f", (double)a4 / tot_a4);
if (a5 == 0) cout << " N";
else cout << " " << a5 << endl;
//system("pause");
return 0;

}