1836 {
1837 int n;
1838 cin >> n;
1839 string x;
1840 long double sum = 0;
1841 int k = 0;
1842 while(n-- != 0) {
1843 cin >> x;
1844 bool flag = true;
1845 int start = 0;
1846 if(x[0] == '-') {
1847 if(x.length() > 1) {
1848 start = 1;
1849 } else {
1850 goto ERROR;
1851 }
1852 }
1853 if(x.length() > 8) {
1854 goto ERROR;
1855 }
1856 if(isdigit(x[start]) != 0) {
1857 int pos = -1;
1858 for(int i = start + 1; i < x.length(); ++i) {
1859 if(x[i] == '.') {
1860 if(flag) {
1861 flag = false;
1862 pos = i;
1863 } else {
1864 goto ERROR;
1865 }
1866 } else if(isdigit(x[i]) == 0) {
1867 goto ERROR;
1868 }
1869 }
1870 if(!flag) {
1871 if(pos + 3 < x.length()) {
1872 goto ERROR;
1873 }
1874 }
1875 stringstream ss;
1876 ss << x;
1877 if(flag) {
1878 int num;
1879 ss >> num;
1880 if(num >= -1000 && num <= 1000) {
1881 sum += num;
1882 k++;
1883 } else {
1884 goto ERROR;
1885 }
1886 } else {
1887 long double num;
1888 ss >> num;
1889 if(num >= -1000 && num <= 1000) {
1890 sum += num;
1891 k++;
1892 } else {
1893 goto ERROR;
1894 }
1895 }
1896 } else {
1897 ERROR:
1898 cout << "ERROR: " << x << " is not a legal number" << endl;
1899 }
1900 }
1901 if(k == 0) {
1902 cout << "The average of 0 numbers is Undefined" << endl;
1903 } else {
1904 const long double y = sum / k;
1905 cout << "The average of " << k << " number" << (k == 1 ? "" : "s") << " is " << fixed << setprecision(2) << y << endl;
1906 }
1907 return 0;
1908 }