#include <bits/stdc++.h>
using namespace std;
const int N = 400;
int n, m, dp[N][N][N + 1], a[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) dp[i][j][0] = a[j] - a[i];
  for (int k = 1; k <= n; k++)
    for (int i = 0; i < n; i++)
      for (int j = i, w = i; j < n; j++) {
        while (w + 1 <= j && max(dp[i][w][k - 1], a[j] - a[w]) >=
                                 max(dp[i][w + 1][k - 1], a[j] - a[w + 1]))
          w++;
        dp[i][j][k] = max(dp[i][w][k - 1], a[j] - a[w]);
      }
  long long ans = 0;
  for (int i = 0, a, b, c, d; i < m; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    ans = max(ans, c * 1LL * dp[a - 1][b - 1][d]);
  }
  printf("%lld\n", ans);
}
