#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e2 + 2;
int rd() {
  int x;
  scanf("%d", &x);
  return x;
}
int dp[maxn][maxn][maxn], a[maxn];
void calc_dp(int n) {
  for (int st = 1; st <= n; st++)
    for (int ed = st + 1; ed <= n; ed++) dp[0][st][ed] = a[ed] - a[st];
  for (int k = 1; k <= n; k++) {
    for (int st = 1; st <= n; st++) {
      int lst = st;
      for (int ed = st + 1; ed <= n; ed++) {
        while (lst < ed && max(dp[k - 1][st][lst], a[ed] - a[lst]) >
                               max(dp[k - 1][st][lst + 1], a[ed] - a[lst + 1]))
          lst++;
        dp[k][st][ed] = max(dp[k - 1][st][lst], a[ed] - a[lst]);
      }
    }
  }
}
int main() {
  int n = rd(), m = rd();
  for (int ed = 1; ed <= n; ed++) a[ed] = rd();
  calc_dp(n);
  long long ans = 0;
  while (m--) {
    int st = rd(), ed = rd(), price = rd(), k = rd();
    ans = max(ans, 1LL * dp[k][st][ed] * price);
  }
  printf("%lld\n", ans);
  return 0;
}
