#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, m;
long long dp[2][404][404], a[404];
vector<tuple<int, int, int> > q[404];
inline long long calc(int k, int i, int p, int j) {
  return max(dp[k & 1][i][p], a[j] - a[p]);
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 1; i <= m; ++i) {
    int s = read(), t = read(), c = read(), r = read();
    q[r + 1].emplace_back(s, t, c);
  }
  memset(dp[0], 0x3f, sizeof(dp[0]));
  for (int i = 1; i <= n; ++i) {
    dp[0][i][i] = 0;
  }
  long long ans = 0;
  for (int k = 1; k <= n + 1; ++k) {
    for (int i = 1; i <= n; ++i) {
      int p = i;
      dp[k & 1][i][i] = 0;
      for (int j = i + 1; j <= n; ++j) {
        while (p < j - 1 && calc(k - 1, i, p + 1, j) <= calc(k - 1, i, p, j))
          ++p;
        dp[k & 1][i][j] = calc(k - 1, i, p, j);
      }
    }
    for (auto [s, t, c] : q[k]) {
      ans = max(ans, dp[k & 1][s][t] * c);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
