#!/usr/bin/python3 code = [] with open("input") as fh: for ln in fh: code.append(int(ln)) def valid(code, o): for i in range(o - 25, o - 1): for j in range(i, o): if code[i] + code[j] == code[o]: return True for o in range(25, len(code)): if not valid(code, o): print(o, code[o])