#include <bits/stdc++.h>
using namespace std;
struct N {
  long long t, c, r;
  N(long long t = 0, long long c = 0, long long r = 0) : t(t), c(c), r(r) {}
};
vector<N> G[500005];
long long a[505], dp[505][505], s, t, c, r, ans;
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    scanf("%lld%lld%lld%lld", &s, &t, &c, &r);
    G[s].push_back(N(t, c, r));
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      dp[j][0] = a[j] - a[i];
      int p = i;
      for (int k = 1; k <= n; k++) {
        dp[j][k] = a[j] - a[i];
        while (p + 1 <= j && dp[p + 1][k - 1] <= a[j] - a[p + 1]) p++;
        dp[j][k] = min(dp[j][k], min(dp[p + 1][k - 1], a[j] - a[p]));
      }
    }
    for (auto u : G[i]) ans = max(dp[u.t][u.r] * u.c, ans);
  }
  cout << ans;
}
