public static void main(String[] args) {
//		System.out.println(Euler.gcd(27, 9));
		int limit = 120000;
		long sum=0;
		
		for (int a = 0; a < limit/2; ++a) {
			for (int b = a+1; true; ++b) {
				int c=a+b;
				if (c>limit)
					break;
				if (gcd(a,b)!=1 || gcd(a,c)!=1 || gcd(b,c)!=1)
					continue;
				if ((long)((long)rad(a)*(long)rad(b)*(long)rad(c)) < (long)c) {
					sum+=c;
				}
			}
			if (a % 10 == 0)
				System.out.println(a);
		}
		System.out.println(sum);
	}