#include <iostream>
#include <string>
using namespace std;
int main() {
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
int res;
if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0) {
res= 0;
} else {
int abcd = (a == 0 ? 1 : a) * (b == 0 ? 1 : b) * (c == 0 ? 1 : c) * (d == 0 ? 1 : d);
int sum = (a == 0 ? 0 : 1) * (b == 0 ? 1 : b) * (c == 0 ? 1 : c) * (d == 0 ? 1 : d) + (a == 0 ? 1 : a) * (b == 0 ? 0 : 1) * (c == 0 ? 1 : c) * (d == 0 ? 1 : d) + (a == 0 ? 1 : a) * (b == 0 ? 1 : b) * (c == 0 ? 0 : 1) * (d == 0 ? 1 : d) + (a == 0 ? 1 : a) * (b == 0 ? 1 : b) * (c == 0 ? 1 : c) * (d == 0 ? 0 : 1);
int all;
res = (e!=0&&(e * abcd) % (abcd - sum) == 0&&(all = (e * abcd) / (abcd - sum))% (a == 0 ? 1 : a) == 0&& all % (b == 0 ? 1 : b) == 0 && all % (c == 0 ? 1 : c) == 0 && all % (d == 0 ? 1 : d) == 0)?all:-1;
}
cout<<res;
}
I2luY2x1ZGUgPGlvc3RyZWFtPiAKI2luY2x1ZGUgPHN0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKSB7CiAgICBpbnQgYSwgYiwgYywgZCwgZTsKICAgIGNpbiA+PiBhID4+IGIgPj4gYyA+PiBkID4+IGU7CiAgICBpbnQgcmVzOwogICAgaWYgKGEgPT0gMCAmJiBiID09IDAgJiYgYyA9PSAwICYmIGQgPT0gMCAmJiBlID09IDApIHsKICAgICAgICByZXM9IDA7CiAgICB9IGVsc2UgewogICAgICAgIGludCBhYmNkID0gKGEgPT0gMCA/IDEgOiBhKSAqIChiID09IDAgPyAxIDogYikgKiAoYyA9PSAwID8gMSA6IGMpICogKGQgPT0gMCA/IDEgOiBkKTsKICAgICAgICBpbnQgc3VtID0gKGEgPT0gMCA/IDAgOiAxKSAqIChiID09IDAgPyAxI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