#include <bits/stdc++.h>
using namespace std;
long long ar[3][3], n, ans, minn, maxn;
int main() {
  cin >> n >> ar[0][1] >> ar[1][0] >> ar[1][2] >> ar[2][1];
  minn = min(min(ar[0][1] + ar[1][0], ar[0][1] + ar[1][2]),
             min(ar[2][1] + ar[1][0], ar[2][1] + ar[1][2]));
  maxn = max(max(ar[0][1] + ar[1][0], ar[0][1] + ar[1][2]),
             max(ar[2][1] + ar[1][0], ar[2][1] + ar[1][2]));
  ans = max((long long)0, n * (n + (minn - maxn)));
  cout << ans;
}
